<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">
<script>
    (function () {
        if ('') {
            if (prompt('请输入文章密码') !== '') {
                alert('密码错误！');
                if (history.length === 1) {
                    location.replace("https://google.com"); // 这里替换成你的首页
                } else {
                    history.back();
                }
            }
        }
    })();
</script>








<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">










<meta property="og:type" content="website">
<meta property="og:title" content="苏生不惑的博客">
<meta property="og:url" content="http://yoursite.com/page/31/index.html">
<meta property="og:site_name" content="苏生不惑的博客">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="苏生不惑的博客">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/page/31/">



<meta name="referrer" content="never"> ​​​​


  <title>苏生不惑的博客</title>
  








</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">苏生不惑的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/26/买书一时爽，看书如抽丝/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/08/26/买书一时爽，看书如抽丝/" itemprop="url">买书一时爽，看书如抽丝</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-26T19:57:07+08:00">
                2019-08-26
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  901 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  3 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>这是一篇旧文。</p>
<p>又到周五，公众号也许久未更新了，现在正好来写写，明天周末好好休息，这几天太累了。</p>
<p>此刻正在听喜马拉雅的《晚上十点》直播，直播地址<a href="http://liveroom.ximalaya.com/live/10320" target="_blank" rel="noopener">http://liveroom.ximalaya.com/live/10320</a> 我手机上装的 APP 不过 20 个左右，喜马拉雅是我比较喜欢的 APP，每天上班路上会听听。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-5caf499c5a74e0cf?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>这次五一回了趟家，火车上无聊看了本书《程序是怎样跑起来的》，从计算机的内部结构开始讲起，以图配文的形式详细讲解了二进制、内存、数据压缩、源文件和可执行文件、操作系统和应用程序的关系、汇编语言、硬件控制方法等内容，还是比较有趣的，原来代码的执行过程是这样的：</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-16b2f4799bbd1e1b?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-6ca7143d8b6cb1e7?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>程序是指令和数据的组合，如c语言的printf(‘hello world’),printf 是执行，hello world 是数据。</p>
<p>cpu能识别和执行的语言只有机器语言，使用java，Python编写的语言，最后都会转换为机器语言。磁盘上写的程序被复制到内存才能运行，根据程序指令进行数据运算，并控制计算机的就是cpu。</p>
<p>数据是用二进制数表示的，因为集成电路上的电压只有两种状态，正好用0和1来表示，于是有了二进制，位，字节等。</p>
<p>计算机进行小数运算时出错，比如 for 循环 100 次累加 0.1 也得不到 10，这是因,0.1 不能完整用二进制来表示，就像 100 / 3 等于33.333333333…，无限循环个3，所以要避免出错有两个途径：</p>
<p>如果不在乎精度，可以进行截取；</p>
<p>循环 100 次加 1 然后除以 10 就可以了。</p>
<p>javascript 中console.log(0.1+0.2) 不等于0.3，而是 0.30000000000000004，也是基于浮点数不能完整用二进制来表示的缘故，而且大多数语言都是如此，有个网站 0.30000000000000004.com 可以看到。</p>
<p>平常处理支付牵涉钱，数据库一般用 decimal 来存，也可以参考微信支付用分来处理，1 块钱等于 100 分，这样就不用担心编程语言中浮点数精度问题而导致钱数对不上。</p>
<p>这本书还讲了许多，还没看完，不过还是有收获的。这是今年看的第一本书，想起来真是惭愧，互联网时代，真是难得静下心来好好看一本书了，所谓：买书一时爽，看书如抽丝。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-7ebe653f9ccdcc9a?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>这是家里的书，许多书还未翻看，再也找不回当年上大学时看 当年明月 的七部《明朝那些事儿》那种激情。</p>
<p>回家听我爸说老家的地和山都要被征完了，现在都建工业区了，以后可以再建大点的新房子，然后出租给附近工厂上班的，发展真是快啊。卖地的钱有几千万了，按人头来分，每人能分几万吧，钱是不多，不过好多人就开始急着结婚，生孩子了，人多分得多嘛，然后我爸来催我，哎，不说这个了，幸福冷暖自知。</p>
<p>这次又陪小朋友（外甥）看了会《喜洋洋》，每次回去小孩都喜欢看，这就是童年乐趣吧。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-6581ed335180868d?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>每篇文章推荐一个工具：视频下载工具 <a href="http://v.atob.site/" target="_blank" rel="noopener">http://v.atob.site/</a> ，支持微博，秒拍，腾讯等，bilibili 的话推荐 <a href="http://www.jijidown.com" target="_blank" rel="noopener">http://www.jijidown.com</a> 更全的有硕鼠 <a href="http://www.flvcd.com/" target="_blank" rel="noopener">http://www.flvcd.com/</a></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/26/如何免费在线听周杰伦的歌曲/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/08/26/如何免费在线听周杰伦的歌曲/" itemprop="url">如何免费在线听周杰伦的歌曲</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-26T15:14:12+08:00">
                2019-08-26
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.1k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  4 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>我平常用网易云来听音乐 <a href="http://music.163.com/" target="_blank" rel="noopener">http://music.163.com/</a> ，网易云除了歌好听，评论更有故事。</p>
<p>之前已经写过网易云音乐了，有兴趣看看之前的文章<a href="https://mp.weixin.qq.com/s/LtI2piwAIDXA590NEsXvuw" target="_blank" rel="noopener">那些你可能不知道的网易云音乐奇技淫巧</a></p>
<p>可惜周杰伦的大部分歌曲网易没有版权，还好我保存了一份杰伦所有的歌曲，如果你也想收藏的话公众号回复 <code>周杰伦</code> 获取。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-325df84a8cceef93.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>那首评论过百万的神曲《晴天》已经变成灰色。<a href="https://music.163.com/#/song?id=186016" target="_blank" rel="noopener">https://music.163.com/#/song?id=186016</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-b97b59639929a4ec.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-14e439051aadfd20.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>这首歌的版权在QQ音乐<a href="https://y.qq.com/n/yqq/song/0039MnYb0qxYhV.html" target="_blank" rel="noopener">https://y.qq.com/n/yqq/song/0039MnYb0qxYhV.html</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-6a67e0b6c4322613.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>而另外有些歌在虾米才有版权可以播放，所以你听一首歌的话可能需要到3个网站找，比较麻烦，这里推荐几个聚合网易，QQ，虾米，酷狗等音乐网站的工具/网站。</p>
<h3 id="listen1"><a href="#listen1" class="headerlink" title="listen1"></a>listen1</h3><p>Listen 1可以搜索和播放来自网易云音乐，虾米，QQ音乐，酷狗音乐，酷我音乐网站的歌曲，让你的曲库更全面。<a href="http://listen1.github.io/listen1/" target="_blank" rel="noopener">http://listen1.github.io/listen1/</a></p>
<p>它提供了Chrome插件版，win桌面版（直接exe安装），mac桌面版，Linux桌面版，我下载的是Chrome插件版，关于插件我之前也写过一篇<a href="https://mp.weixin.qq.com/s/adJFh_9LH0N-vvvYaiQqXg" target="_blank" rel="noopener">Chrome 浏览器扩展神器油猴</a></p>
<p>安装后使用的界面是这样的。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-659c825a87620eb7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>它集合了网易云音乐，虾米音乐，QQ音乐，酷狗音乐，酷我音乐，哔哩哔哩，咪咕音乐这几个网站的音乐资源，可以说很齐全了，比如搜索《再见二丁目》，点击就可以直接播放了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-69b49508cfe362b1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="音乐聚合搜索"><a href="#音乐聚合搜索" class="headerlink" title="音乐聚合搜索"></a>音乐聚合搜索</h3><p>这种聚合搜索不限定某个网站，谷歌搜索下有很多这样的网站，如果其中某个网站挂了，换一个就是了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-22807ed2a802753e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>比如第一个<a href="http://www.gequdaquan.net/gqss/" target="_blank" rel="noopener">http://www.gequdaquan.net/gqss/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-58b4115f91f269ba.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>直接搜索就好。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-a9bb391f048ec3bf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>搜索结果中第3个<a href="https://music.8ziyuan.com/" target="_blank" rel="noopener">https://music.8ziyuan.com/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-c240fbb95f9c0a24.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>这种网站是基于开源程序搭建的，开源地址 <a href="https://github.com/maicong/music/，" target="_blank" rel="noopener">https://github.com/maicong/music/，</a> 如果你会代码并有自己服务器的话也可以建一个这样的音乐聚合网站。</p>
<p>这里说下这个网站，可以直接免费在线听周杰伦歌曲，还能下载，不知道这个网站能存在多久，先收藏吧。<br><a href="http://tool.liumingye.cn/music/?type=migu&amp;name=%E5%91%A8%E6%9D%B0%E4%BC%A6" target="_blank" rel="noopener">http://tool.liumingye.cn/music/?type=migu&amp;name=%E5%91%A8%E6%9D%B0%E4%BC%A6</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-d399c3105f3e31ad.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="音乐下载"><a href="#音乐下载" class="headerlink" title="音乐下载"></a>音乐下载</h3><p>上面的聚合网站也可以直接下载歌曲，不过也有人开发了这样的下载工具，比如Music-Downloader ，这是一款简单的音乐下载（播放）器， 功能有歌曲搜索、歌单读取、在线播放、歌曲下载（包括付费音乐），下载地址 <a href="https://github.com/messoer/Music-Downloader/releases/download/1.4.2/MusicDownloader.zip" target="_blank" rel="noopener">https://github.com/messoer/Music-Downloader/releases/download/1.4.2/MusicDownloader.zip</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-13ba8ef4fde88e52.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><img src="https://upload-images.jianshu.io/upload_images/17817191-19781e3d036fafe0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>当然我更喜欢用命令行来下载，详细见之前的文章 <a href="https://mp.weixin.qq.com/s/LtI2piwAIDXA590NEsXvuw" target="_blank" rel="noopener">那些你可能不知道的网易云音乐奇技淫巧</a></p>
<p>比如下载五月天的专辑《自传》，直接<code>music-get https://y.qq.com/n/yqq/album/002fRO0N4FftzY.html</code><br><img src="https://upload-images.jianshu.io/upload_images/17817191-c50a453e2f5a0dae.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="资源"><a href="#资源" class="headerlink" title="资源"></a>资源</h3><p>全网音乐免费下载工具<a href="https://music.sonimei.cn/" target="_blank" rel="noopener">https://music.sonimei.cn/</a> <a href="https://music.sonimei.cn/yinyue/" target="_blank" rel="noopener">https://music.sonimei.cn/yinyue/</a><br>网易云音乐、QQ音乐一键下载工具<a href="https://github.com/winterssy/music-get" target="_blank" rel="noopener">https://github.com/winterssy/music-get</a><br>一个现代音乐播放器 <a href="https://github.com/PeterDing/chord" target="_blank" rel="noopener">https://github.com/PeterDing/chord</a><br>多站合一音乐搜索解决方案 <a href="https://github.com/maicong/music/" target="_blank" rel="noopener">https://github.com/maicong/music/</a><br>网易云音乐nodejs api：<a href="https://github.com/Binaryify/NeteaseCloudMusicApi" target="_blank" rel="noopener">https://github.com/Binaryify/NeteaseCloudMusicApi</a><br>一个可以播放“任意”音乐的播放器<a href="https://github.com/feeluown/FeelUOwn" target="_blank" rel="noopener">https://github.com/feeluown/FeelUOwn</a><br>chrome插件：声海盗，下载在线音乐插件，支持豆瓣，虾米，QQ音乐，网易云音乐等<a href="https://github.com/seekerlee/SoundPirate" target="_blank" rel="noopener">https://github.com/seekerlee/SoundPirate</a><br>如何愉快使用网易云音乐，解锁变灰歌曲！<a href="https://github.com/nondanee/UnblockNeteaseMusic" target="_blank" rel="noopener">https://github.com/nondanee/UnblockNeteaseMusic</a><br>一款简单的音乐下载（播放）器 功能：歌曲搜索、歌单读取、在线播放、歌曲下载（包括付费音乐） ​​​​ <a href="https://github.com/messoer/Music-Downloader/releases" target="_blank" rel="noopener">https://github.com/messoer/Music-Downloader/releases</a> <a href="https://github.com/sevenJia/music" target="_blank" rel="noopener">https://github.com/sevenJia/music</a><br>Vue 全家桶高仿网易云音乐 mac 客户端版 <a href="https://github.com/sl1673495/vue-netease-music" target="_blank" rel="noopener">https://github.com/sl1673495/vue-netease-music</a><br>qq 音乐解析网站 <a href="http://www.66it.top/" target="_blank" rel="noopener">http://www.66it.top/</a></p>
<p>推荐阅读:</p>
<p><a href="https://mp.weixin.qq.com/s/Xz1m-mqtCcBF_4hmGCpkUQ" target="_blank" rel="noopener">如何发一条空白的朋友圈</a></p>
<p><a href="https://mp.weixin.qq.com/s/_3AeNahwbs8c3UJ0is1t4A" target="_blank" rel="noopener">如何在电脑上登陆多个微信</a></p>
<p><a href="https://mp.weixin.qq.com/s/qyFvOgHf1mXwPKO0tQwUyg" target="_blank" rel="noopener">如何提取公积金 9 天到账</a></p>
<p><a href="https://mp.weixin.qq.com/s/-cSjrvkibYGp5Fx8gCTFuw" target="_blank" rel="noopener">那些你可能不知道的浏览器奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/eGDO0Y8el_dsEyriCoAgog" target="_blank" rel="noopener">那些你可能不知道的微信奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/LtI2piwAIDXA590NEsXvuw" target="_blank" rel="noopener">那些你可能不知道的网易云音乐奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/5InOxKmi9eXk33G_8N3byQ" target="_blank" rel="noopener">那些你可能不知道的视频下载奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/R3x-xZwqLIVwPjlgikDQ9A" target="_blank" rel="noopener">那些你可能不知道的免费观看 VIP 视频奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/sqRgMh4rxFBt5YxNtaa6dw" target="_blank" rel="noopener">那些你可能不知道的知乎奇技淫巧</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-393b26173c148690.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="免费星球"></p>
<h3 id="公众号：苏生不惑"><a href="#公众号：苏生不惑" class="headerlink" title="公众号：苏生不惑"></a>公众号：苏生不惑</h3><p> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/23/博客推荐/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/08/23/博客推荐/" itemprop="url">博客推荐</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-23T17:01:47+08:00">
                2019-08-23
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  250 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  1 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="github"><a href="#github" class="headerlink" title="github"></a>github</h3><p><a href="https://alpha2016.github.io/about/" target="_blank" rel="noopener">何晓东PHP开发工程师</a></p>
<p><a href="http://cuihuan.net/" target="_blank" rel="noopener">靠谱崔小拽</a></p>
<p><a href="https://lbjheiheihei.xyz/about.html" target="_blank" rel="noopener">伪君子</a></p>
<p><a href="https://www.yoby123.cn/" target="_blank" rel="noopener">小白的分享</a></p>
<p><a href="https://www.cnblogs.com/52fhy/" target="_blank" rel="noopener">飞鸿影的博客</a></p>
<p>   <a href="https://tingtalk.me/" target="_blank" rel="noopener">庭说</a> </p>
<p><a href="https://blog.nightteam.cn/" target="_blank" rel="noopener">夜幕</a></p>
<p><a href="http://blog.xiayf.cn/archives.html" target="_blank" rel="noopener">黑白</a></p>
<p><a href="https://post.zz173.com/detail/hfu17Yn_YpMY9TlVNTqv8w.html" target="_blank" rel="noopener">青枫浦</a></p>
<p><a href="https://lbjheiheihei.xyz/archives.html" target="_blank" rel="noopener">伪君子的梦呓</a></p>
<p><a href="https://me.jinchuang.org/archives/301.html" target="_blank" rel="noopener">靳闯博客</a></p>
<p><a href="https://93nv.com/archives/category/%E7%BC%96%E7%A8%8B%E5%B7%A5%E5%85%B7" target="_blank" rel="noopener">痴海日报</a></p>
<p><a href="http://www.golang365.com/#/" target="_blank" rel="noopener">天行九歌</a></p>
<p><a href="http://einverne.github.io/post/2019/01/html-to-pdf.html" target="_blank" rel="noopener">每天学习一个命令</a></p>
<p><a href="https://haoruijie.art/archives/page/3/" target="_blank" rel="noopener">彩虹马厩laravel</a></p>
<p><a href="https://godruoyi.com/posts/About-godruoyi" target="_blank" rel="noopener">godruoyi php</a></p>
<p><a href="https://www.awaimai.com/about" target="_blank" rel="noopener">歪麦博客</a></p>
<p><a href="https://hoxis.github.io/archives/" target="_blank" rel="noopener">不正经程序员</a></p>
<p><a href="http://www.54php.cn/default/about" target="_blank" rel="noopener">编程浪子</a></p>
<p><a href="https://tianyong90.com/" target="_blank" rel="noopener">larvel田写</a></p>
<p><a href="http://efonfighting.imwork.net/" target="_blank" rel="noopener">一番码客 </a></p>
<p><a href="https://93nv.com/" target="_blank" rel="noopener">痴海</a></p>
<p><a href="https://www.qqdeveloper.com/about/" target="_blank" rel="noopener">php qqdeveloper</a></p>
<p><a href="https://oicebot.github.io/titles" target="_blank" rel="noopener">python数据科学分析</a></p>
<p><a href="https://bettercuicui.github.io/" target="_blank" rel="noopener">cuicui 数据库Redis</a></p>
<p><a href="https://www.xjcbt.com/18.html" target="_blank" rel="noopener">软件工具分享</a></p>
<p><a href="https://www.kuajie.me/friends/" target="_blank" rel="noopener">跨界思考享赚钱思路</a></p>
<h3 id="安全"><a href="#安全" class="headerlink" title="安全"></a>安全</h3><p>plaidCTF两道web题目writeup <a href="http://blog.wonderkun.cc/2019/04/15/plaidCTF%E4%B8%A4%E9%81%93web%E9%A2%98%E7%9B%AEwriteup/" target="_blank" rel="noopener">http://blog.wonderkun.cc/2019/04/15/plaidCTF%E4%B8%A4%E9%81%93web%E9%A2%98%E7%9B%AEwriteup/</a><br>ctf <a href="https://www.yof3ng.xyz/" target="_blank" rel="noopener">https://www.yof3ng.xyz/</a><br>PHP中的危险函数和伪协议<a href="https://anemone.top/php-PHP%E4%B8%AD%E7%9A%84%E5%8D%B1%E9%99%A9%E5%87%BD%E6%95%B0%E5%92%8C%E4%BC%AA%E5%8D%8F%E8%AE%AE/" target="_blank" rel="noopener">https://anemone.top/php-PHP%E4%B8%AD%E7%9A%84%E5%8D%B1%E9%99%A9%E5%87%BD%E6%95%B0%E5%92%8C%E4%BC%AA%E5%8D%8F%E8%AE%AE/</a><br>基于 electron-vue 开发了一个美图搜罗器<a href="https://github.com/Licoy/girls-reptile/releases" target="_blank" rel="noopener">https://github.com/Licoy/girls-reptile/releases</a></p>
<p>拍片哥-红色导航网站网址-福利导航 <a href="https://bbs.918dxs.com/topics/3772/lan-se-dao-hang" target="_blank" rel="noopener">https://bbs.918dxs.com/topics/3772/lan-se-dao-hang</a></p>
<p><a href="https://anemone.top/archives/" target="_blank" rel="noopener">关注Web安全anemone</a></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/19/如何在豆瓣租房小组快速找到满意的房子/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/08/19/如何在豆瓣租房小组快速找到满意的房子/" itemprop="url">如何在豆瓣租房小组快速找到满意的房子</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-19T20:22:35+08:00">
                2019-08-19
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2.1k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  7 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>这几天忙着找房子，没怎么更新公众号，新浪本来是提供人才公寓的，可惜我错过了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-b87755ef9af0f05f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>在大城市租房真的是一把辛酸泪，至今不知道搬家多少次了，今天就分享下我在北京租房找房的经历，或许对你找房子（不限于北京）有点借鉴作用。</p>
<p>先说说租房的坑。</p>
<h3 id="不要租隔断"><a href="#不要租隔断" class="headerlink" title="不要租隔断"></a>不要租隔断</h3><p>去年开始北京开始全力打击群租隔断，微博上可以看到不少被拆的案例 <a href="https://weibo.com/6046360157/HEHMAipBj?refer_flag=1001030103" target="_blank" rel="noopener">https://weibo.com/6046360157/HEHMAipBj?refer_flag=1001030103</a>_ ，所以为了安全，还是不要图便宜，宁愿多花点钱住个次卧或者主卧。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-8eb7f913b4ea1c33.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-20916ef57cece598.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="远离长租公寓"><a href="#远离长租公寓" class="headerlink" title="远离长租公寓"></a>远离长租公寓</h3><p>Google搜索下 长租公寓 跑路 可以看到很多人被坑的案例。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-a6fd6775260e6a83.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>这种公寓用你的的个人信息去 p2p 分期贷款，你以为和公寓签的是租房合同，实际上却是贷款合同，一旦公寓跑路，房子被房东收回，你还得接着还贷款，更可恶的是可能影响了你的个人征信，对你以后买房什么的造成不可估量的影响。</p>
<p> 36kr和观察者就曾报道过<br>一位中介深喉的讲述：长租公寓可以繁荣，也可以让上万人无家可归<a href="https://36kr.com/p/5167950.html" target="_blank" rel="noopener">https://36kr.com/p/5167950.html</a><br>长租公寓：含笑埋的雷，跪着也要爆完<a href="https://36kr.com/p/5157879.html?from=guess" target="_blank" rel="noopener">https://36kr.com/p/5157879.html?from=guess</a><br>长租公寓租房贷引争议：交完押金才发现背了贷款 <a href="https://www.guancha.cn/economy/2018_08_22_469220.shtml" target="_blank" rel="noopener">https://www.guancha.cn/economy/2018_08_22_469220.shtml</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-f39024c74f980174.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>所以千万要小心，我只说了2个坑，可能还有其他更大的坑，大家也可以分享下自己租房遇到过的坑。</p>
<p>说完了坑然后说说怎么找到自己满意的房子。</p>
<h3 id="链家自如"><a href="#链家自如" class="headerlink" title="链家自如"></a>链家自如</h3><p>这2个比较靠谱和方便，当然也比较贵了，如果你不缺钱的话直接选这2个就行，下面不用看了。</p>
<h3 id="豆瓣租房小组"><a href="#豆瓣租房小组" class="headerlink" title="豆瓣租房小组"></a>豆瓣租房小组</h3><p>豆瓣电影大家都知道，其实豆瓣上还可以租房的，上面有许多租房信息，更新非常快。<br>去年豆瓣还发布了自己的<a href="https://mp.weixin.qq.com/s/vz6-hqwHnIdQXhvQK9EtLA" target="_blank" rel="noopener">豆瓣租房小程序</a>    <a href="https://www.douban.com/note/667954828/" target="_blank" rel="noopener">https://www.douban.com/note/667954828/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-d82498637e86d971.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>然而不知为何今年4月4号却下线了，这是<a href="https://mp.weixin.qq.com/s/Fl3fnX64HbVxjVAQ8v2jeQ" target="_blank" rel="noopener">下线公告</a>，不过好在还有豆瓣小组，进入豆瓣小组搜索租房就可以看到各个城市的小组。<a href="https://www.douban.com/group/search?cat=1019&amp;q=%E7%A7%9F%E6%88%BF" target="_blank" rel="noopener">https://www.douban.com/group/search?cat=1019&amp;q=%E7%A7%9F%E6%88%BF</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-8f1129ab72a9b28e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>比如北京的话推荐这几个小组 <a href="https://www.douban.com/group/625354/" target="_blank" rel="noopener">https://www.douban.com/group/625354/</a>，<a href="https://www.douban.com/group/625354/?ref=sidebar" target="_blank" rel="noopener">https://www.douban.com/group/625354/?ref=sidebar</a><br>豆瓣上合租比较多，而且不要中介费 ，如果能找到人一起合租是最好的了。</p>
<p>但是豆瓣小组的帖子更新非常快，而且没有搜索功能，如果一页一页的翻，真的会累死人，所以还是得靠搜索引擎，关于搜索引擎的使用技巧，我之前写过一篇文章，强烈建议你看看<br> <a href="https://mp.weixin.qq.com/s/-5tZWfeWWa_E8jRCH0T_Cw" target="_blank" rel="noopener">那些你可能不知道的搜索奇技淫巧</a></p>
<p>我住在回龙观地铁附近，所以就直接搜索 site:douban.com 回龙观合租，时间选择一周内，因为太久的信息已经失效了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-28dfddddcd3a4c4d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>进入第三个链接 <a href="https://www.douban.com/group/topic/146110587/" target="_blank" rel="noopener">https://www.douban.com/group/topic/146110587/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-6041820d9832bc68.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>对方没有提供手机号，而是微信，搜索下微信号，发现对方只发过2个豆瓣帖子，可以肯定不是中介。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-7414536ff882160e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>于是我加了对方微信，第二天就直接过去了，房子还不错，可惜离地铁有点远，而且附近没有超市，吃饭也麻烦，于是放弃了。</p>
<p>继续往下翻，看到这个帖子<a href="https://www.douban.com/group/topic/147579647/" target="_blank" rel="noopener">https://www.douban.com/group/topic/147579647/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-2028afe02f686c12.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>直接搜索对方手机号，有7页搜索记录，不同时间发布那么多租房信息，百分百中介，告辞。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-8b4f146597f4d554.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>继续搜，看到这个帖子，对方也只提供微信号，搜索了下只有几条记录，先加微信。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-271d5ec37d0904d3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>过去后看了下房子，房子是他和房东直接租的，离地铁比较近，附近有商场，吃饭什么的也方便，好，交押金先定了。</p>
<p>看豆瓣帖子总结就是：<br>描述写了一大堆，价格也不写还要求电话联系，放弃。<br>照片拍得不错，房间非常整齐，搜索下图片发现很多地方见过，放弃。<br>搜索对方微信或者手机号，一大堆租房信息，放弃。</p>
<p>最后还是感谢豆瓣让我找到了满意的房子。</p>
<h3 id="水木社区"><a href="#水木社区" class="headerlink" title="水木社区"></a>水木社区</h3><p>这是个比较小众的社区，所以进入的中介也少，上面有不少房东发布的房源。<a href="http://www.newsmth.net/nForum/#!board/HouseRent" target="_blank" rel="noopener">http://www.newsmth.net/nForum/#!board/HouseRent</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-d4e2efd2ce303d69.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="u租"><a href="#u租" class="headerlink" title="u租"></a>u租</h3><p>网址 <a href="http://bj.yurixu.com/manage/beijing.php#" target="_blank" rel="noopener">http://bj.yurixu.com/manage/beijing.php#</a>  因为豆瓣的搜索效率很低，这个网站集合了豆瓣，水木社区和北邮人上的租房信息，可以根据地区和地铁线路搜索，可惜目前只支持北京和上海。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-6fbb8ef5dfba7610.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>搜索关键词和筛选比直接用豆瓣高效多了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-efc4625eb898a46d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="微博搜索"><a href="#微博搜索" class="headerlink" title="微博搜索"></a>微博搜索</h3><p>微博上有很多租房话题，可以搜索自己对应城市的话题 <a href="https://weibo.com/p/100808e57bb364ea5d7b996e05bedf032aab52/super_index" target="_blank" rel="noopener">https://weibo.com/p/100808e57bb364ea5d7b996e05bedf032aab52/super_index</a><br> ，比如我在的北京，回龙观地铁附近。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-f81ed838464e9dcf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><img src="https://upload-images.jianshu.io/upload_images/17817191-f8f5db835ffcedb4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>看到合适的房子直接微博联系对方就可以了，不过还是得小心黑中介。</p>
<h3 id="小程序"><a href="#小程序" class="headerlink" title="小程序"></a>小程序</h3><p>第一个是六六直租，原英文名称zuber，覆盖了北京、上海、广州、深圳、杭州等多个热门城市,可惜他们网页版不提供联系方式<a href="https://mobile.zuber.im/search/rent，只有上小程序和APP" target="_blank" rel="noopener">https://mobile.zuber.im/search/rent，只有上小程序和APP</a> <a href="http://app.zuber.im/" target="_blank" rel="noopener">http://app.zuber.im/</a> 。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-49fc1a30dafe1e40.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>第二个是暖房小程序，网址<a href="https://nuan.io/hello-wechat" target="_blank" rel="noopener">https://nuan.io/hello-wechat</a>  ，上面有地铁找房，公司找房，避坑指南，我搜了下效果还可以。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-5af5f2b68af1fa2e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="简单租房"><a href="#简单租房" class="headerlink" title="简单租房"></a>简单租房</h3><p>这个网站自动爬取豆瓣房源，自己设置关键字，当豆瓣出现相关租房信息，及时推送到你的微信 <a href="http://house.jiandan.live/" target="_blank" rel="noopener">http://house.jiandan.live/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-385ee2dc130300ba.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="地图搜租房"><a href="#地图搜租房" class="headerlink" title="地图搜租房"></a>地图搜租房</h3><p>这是个人开发的一款找房工具， 作者博客<a href="https://woyaozufang.live/2022/06/04/house-map-move/#more" target="_blank" rel="noopener">https://woyaozufang.live/2022/06/04/house-map-move/#more</a>  地址<a href="https://house-map.cn/#/" target="_blank" rel="noopener">https://house-map.cn/#/</a><br>它支持的平台列表如下：<br>Zuber、豆瓣小组、贝壳租房、豆瓣租房、上海互助租房、CCB 建融家园、58 公寓、蘑菇租房、拼室友、房多多、房天下、嗨住租房、自如、v2ex、巴乐兔租房、安居客租房等，可以说很齐全了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-82fa2046a49930a4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><img src="https://upload-images.jianshu.io/upload_images/17817191-aea306106cd39c77.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>最后说个题外话，租房怎么提取公积金，租房是可以提取公积金的，联系hr向公司提交公积金联名卡和身份证，办理每月 1500 的租房公积金，三个月发一次，也就是每个季度取4500 ，直接打到你的公积金联名卡，我之前的公司也是这样取的，后来到了新浪用的买房提取，有兴趣可以看我之前的文章<a href="https://mp.weixin.qq.com/s/qyFvOgHf1mXwPKO0tQwUyg" target="_blank" rel="noopener">如何提取公积金 9 天到账</a></p>
<h3 id="租房帖子"><a href="#租房帖子" class="headerlink" title="租房帖子"></a>租房帖子</h3><p>8012 北上广深租房不靠谱指南<a href="https://www.v2ex.com/t/506525" target="_blank" rel="noopener">https://www.v2ex.com/t/506525</a><br> <a href="http://zy2071.com/Fun/FindH/#/Homecontent" target="_blank" rel="noopener">http://zy2071.com/Fun/FindH/#/Homecontent</a><br>在北京租房到底要花多少钱？我们整理了一份5000字的攻略 <a href="https://36kr.com/p/5089137" target="_blank" rel="noopener">https://36kr.com/p/5089137</a><br>一位离职中介教你如何在北京租房子 <a href="https://www.jianshu.com/p/0bc163b6f5df" target="_blank" rel="noopener">https://www.jianshu.com/p/0bc163b6f5df</a><br>租房经历总结<a href="http://blog.leanote.com/post/jixn/%E7%A7%9F%E6%88%BF%E5%AD%90" target="_blank" rel="noopener">http://blog.leanote.com/post/jixn/%E7%A7%9F%E6%88%BF%E5%AD%90</a><br><a href="https://sharevideo.cn/?from=groupmessage&amp;isappinstalled=0#/" target="_blank" rel="noopener">https://sharevideo.cn/?from=groupmessage&amp;isappinstalled=0#/</a><br> <a href="http://evilmorty.site/" target="_blank" rel="noopener">豆瓣租房精选</a><br><a href="https://zhuanlan.zhihu.com/p/57698438" target="_blank" rel="noopener">https://zhuanlan.zhihu.com/p/57698438</a><br><a href="https://zhuanlan.zhihu.com/p/26647130" target="_blank" rel="noopener">https://zhuanlan.zhihu.com/p/26647130</a><br><a href="https://www.zhihu.com/question/20741403/answer/364419886" target="_blank" rel="noopener">https://www.zhihu.com/question/20741403/answer/364419886</a><br><a href="https://www.zhihu.com/question/307959368" target="_blank" rel="noopener">有什么事是你租房以后才知道的</a><br><a href="https://www.zhihu.com/question/20741403/answers/updated?page=2" target="_blank" rel="noopener">https://www.zhihu.com/question/20741403/answers/updated?page=2</a><br><a href="https://www.zhihu.com/question/307959368" target="_blank" rel="noopener">https://www.zhihu.com/question/307959368</a><br><a href="https://zhuanlan.zhihu.com/p/26647130" target="_blank" rel="noopener">https://zhuanlan.zhihu.com/p/26647130</a><br><a href="https://www.zhihu.com/question/19988480" target="_blank" rel="noopener">https://www.zhihu.com/question/19988480</a><br><a href="https://zhuanlan.zhihu.com/p/25557696" target="_blank" rel="noopener">https://zhuanlan.zhihu.com/p/25557696</a><br><a href="https://mobile.zuber.im/search/rent" target="_blank" rel="noopener">https://mobile.zuber.im/search/rent</a><br><a href="https://www.zhihu.com/question/39078225" target="_blank" rel="noopener">https://www.zhihu.com/question/39078225</a><br>北京房东直租群<a href="https://www.wenjuan.com/s/7jiyMj/" target="_blank" rel="noopener">https://www.wenjuan.com/s/7jiyMj/</a><br><a href="https://jinshuju.net/f/J64fx0" target="_blank" rel="noopener">https://jinshuju.net/f/J64fx0</a> 密码: faith<br>逃离北上广<a href="https://jinnrry.github.io/getAwayBSG/post/all.html?v=1.0" target="_blank" rel="noopener">https://jinnrry.github.io/getAwayBSG/post/all.html?v=1.0</a></p>
<p> 推荐阅读：</p>
<p><a href="https://mp.weixin.qq.com/s/Xz1m-mqtCcBF_4hmGCpkUQ" target="_blank" rel="noopener">如何发一条空白的朋友圈</a></p>
<p><a href="https://mp.weixin.qq.com/s/_3AeNahwbs8c3UJ0is1t4A" target="_blank" rel="noopener">如何在电脑上登陆多个微信</a></p>
<p><a href="https://mp.weixin.qq.com/s/qyFvOgHf1mXwPKO0tQwUyg" target="_blank" rel="noopener">如何提取公积金 9 天到账</a></p>
<p><a href="https://mp.weixin.qq.com/s/TuJIqv5wv27avFKG8zmJUQ" target="_blank" rel="noopener">我是如何用 Markdown 写公众号文章的</a></p>
<p><a href="https://mp.weixin.qq.com/s/mI5kubVY2t5jwJ9ub7A1iA" target="_blank" rel="noopener">我在新浪的一天工作日常</a></p>
<p> <a href="https://mp.weixin.qq.com/s/-5tZWfeWWa_E8jRCH0T_Cw" target="_blank" rel="noopener">那些你可能不知道的搜索奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/-cSjrvkibYGp5Fx8gCTFuw" target="_blank" rel="noopener">那些你可能不知道的浏览器奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/eGDO0Y8el_dsEyriCoAgog" target="_blank" rel="noopener">那些你可能不知道的微信奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/j7VhoZXmUTnOWC5C_B8jlQ" target="_blank" rel="noopener">那些你可能不知道的微博奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/sqRgMh4rxFBt5YxNtaa6dw" target="_blank" rel="noopener">那些你可能不知道的知乎奇技淫巧</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-393b26173c148690.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="免费星球"></p>
<h3 id="公众号：苏生不惑"><a href="#公众号：苏生不惑" class="headerlink" title="公众号：苏生不惑"></a>公众号：苏生不惑</h3><p> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/14/php-代码整理/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/08/14/php-代码整理/" itemprop="url">php 代码整理</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-14T20:41:02+08:00">
                2019-08-14
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  12.4k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  62 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="不需要递归"><a href="#不需要递归" class="headerlink" title="不需要递归"></a>不需要递归</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">$items = array(</span><br><span class="line">    <span class="number">1</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">1</span>, <span class="string">'pid'</span> =&gt; <span class="number">0</span>, <span class="string">'name'</span> =&gt; <span class="string">' 江西省 '</span>),</span><br><span class="line">    <span class="number">2</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">2</span>, <span class="string">'pid'</span> =&gt; <span class="number">0</span>, <span class="string">'name'</span> =&gt; <span class="string">' 黑龙江省 '</span>),</span><br><span class="line">    <span class="number">3</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">3</span>, <span class="string">'pid'</span> =&gt; <span class="number">1</span>, <span class="string">'name'</span> =&gt; <span class="string">' 南昌市 '</span>),</span><br><span class="line">    <span class="number">4</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">4</span>, <span class="string">'pid'</span> =&gt; <span class="number">2</span>, <span class="string">'name'</span> =&gt; <span class="string">' 哈尔滨市 '</span>),</span><br><span class="line">    <span class="number">5</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">5</span>, <span class="string">'pid'</span> =&gt; <span class="number">2</span>, <span class="string">'name'</span> =&gt; <span class="string">' 鸡西市 '</span>),</span><br><span class="line">    <span class="number">6</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">6</span>, <span class="string">'pid'</span> =&gt; <span class="number">4</span>, <span class="string">'name'</span> =&gt; <span class="string">' 香坊区 '</span>),</span><br><span class="line">    <span class="number">7</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">7</span>, <span class="string">'pid'</span> =&gt; <span class="number">4</span>, <span class="string">'name'</span> =&gt; <span class="string">' 南岗区 '</span>),</span><br><span class="line">    <span class="number">8</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">8</span>, <span class="string">'pid'</span> =&gt; <span class="number">6</span>, <span class="string">'name'</span> =&gt; <span class="string">' 和兴路 '</span>),</span><br><span class="line">    <span class="number">9</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">9</span>, <span class="string">'pid'</span> =&gt; <span class="number">7</span>, <span class="string">'name'</span> =&gt; <span class="string">' 西大直街 '</span>),</span><br><span class="line">    <span class="number">10</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">10</span>, <span class="string">'pid'</span> =&gt; <span class="number">8</span>, <span class="string">'name'</span> =&gt; <span class="string">' 东北林业大学 '</span>),</span><br><span class="line">    <span class="number">11</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">11</span>, <span class="string">'pid'</span> =&gt; <span class="number">9</span>, <span class="string">'name'</span> =&gt; <span class="string">' 哈尔滨工业大学 '</span>),</span><br><span class="line">    <span class="number">12</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">12</span>, <span class="string">'pid'</span> =&gt; <span class="number">8</span>, <span class="string">'name'</span> =&gt; <span class="string">' 哈尔滨师范大学 '</span>),</span><br><span class="line">    <span class="number">13</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">13</span>, <span class="string">'pid'</span> =&gt; <span class="number">1</span>, <span class="string">'name'</span> =&gt; <span class="string">' 赣州市 '</span>),</span><br><span class="line">    <span class="number">14</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">14</span>, <span class="string">'pid'</span> =&gt; <span class="number">13</span>, <span class="string">'name'</span> =&gt; <span class="string">' 赣县 '</span>),</span><br><span class="line">    <span class="number">15</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">15</span>, <span class="string">'pid'</span> =&gt; <span class="number">13</span>, <span class="string">'name'</span> =&gt; <span class="string">' 于都县 '</span>),</span><br><span class="line">    <span class="number">16</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">16</span>, <span class="string">'pid'</span> =&gt; <span class="number">14</span>, <span class="string">'name'</span> =&gt; <span class="string">' 茅店镇 '</span>),</span><br><span class="line">    <span class="number">17</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">17</span>, <span class="string">'pid'</span> =&gt; <span class="number">14</span>, <span class="string">'name'</span> =&gt; <span class="string">' 大田乡 '</span>),</span><br><span class="line">    <span class="number">18</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">18</span>, <span class="string">'pid'</span> =&gt; <span class="number">16</span>, <span class="string">'name'</span> =&gt; <span class="string">' 义源村 '</span>),</span><br><span class="line">    <span class="number">19</span> =&gt; array (<span class="string">'id'</span> =&gt; <span class="number">19</span>, <span class="string">'pid'</span> =&gt; <span class="number">16</span>, <span class="string">'name'</span> =&gt; <span class="string">' 上坝村 '</span>),</span><br><span class="line">);</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">genTree</span>(<span class="params">$items</span>) </span>&#123;</span><br><span class="line">    $tree = array (); <span class="comment">// 格式化好的树</span></span><br><span class="line">    foreach ($items <span class="keyword">as</span> $item)</span><br><span class="line">        <span class="keyword">if</span> (isset($items[$item[<span class="string">'pid'</span>]]))</span><br><span class="line">            $items[$item[<span class="string">'pid'</span>]][<span class="string">'son'</span>][] = &amp;$items[$item[<span class="string">'id'</span>]];</span><br><span class="line">        <span class="keyword">else</span></span><br><span class="line">            $tree[] = &amp;$items[$item[<span class="string">'id'</span>]];</span><br><span class="line">    <span class="keyword">return</span> $tree;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="插入排序算法"><a href="#插入排序算法" class="headerlink" title="插入排序算法"></a>插入排序算法</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Person</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    public $id;</span><br><span class="line">    public $data;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//https://learnku.com/articles/32586</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">insertSort</span>(<span class="params">&amp;$data,$n</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">for</span> ($i=<span class="number">1</span>;$i&lt;$n;$i++)&#123;</span><br><span class="line">        <span class="keyword">if</span> ($data[$i]-&gt;id&lt;$data[$i<span class="number">-1</span>]-&gt;id)&#123;</span><br><span class="line">            $j = $i<span class="number">-1</span>;</span><br><span class="line">            $x = $data[$i]-&gt;id;</span><br><span class="line">            $obj = $data[$i];</span><br><span class="line">            <span class="keyword">while</span>($j&gt;<span class="number">-1</span>&amp;&amp;$x&lt;@$data[$j]-&gt;id)&#123;</span><br><span class="line">                $data[$j+<span class="number">1</span>] = $data[$j];</span><br><span class="line">                $j--;</span><br><span class="line"></span><br><span class="line">            &#125;</span><br><span class="line">            $data[$j+<span class="number">1</span>] = $obj;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line"></span><br><span class="line">    $person = <span class="keyword">new</span> Person();</span><br><span class="line">    $index = [<span class="string">'23'</span>=&gt;<span class="string">'勺颠颠'</span>,<span class="string">'65'</span>=&gt;<span class="string">'老油条'</span>,<span class="string">'21'</span>=&gt;<span class="string">'烧包谷'</span>,<span class="string">'9'</span>=&gt;<span class="string">'烧耳块'</span>,<span class="string">'4'</span>=&gt;<span class="string">'肥嘟嘟'</span>,<span class="string">'7'</span>=&gt;<span class="string">'霉戳戳'</span>,<span class="string">'32'</span>=&gt;<span class="string">'一坨肉'</span>,<span class="string">'6'</span>=&gt;<span class="string">'老扎哇'</span>];</span><br><span class="line">    $data = [];</span><br><span class="line">    foreach ($index <span class="keyword">as</span> $k=&gt;$v)&#123;</span><br><span class="line">        $obj = clone $person;</span><br><span class="line">        $obj-&gt;id = $k;</span><br><span class="line">        $obj-&gt;data = $v;</span><br><span class="line">        $data[] = $obj;</span><br><span class="line">    &#125;</span><br><span class="line">    insertSort($data,<span class="number">8</span>);</span><br><span class="line"></span><br><span class="line">    print_r($data);</span><br><span class="line"></span><br><span class="line">&#125;)();</span><br></pre></td></tr></table></figure>
<h3 id="分表"><a href="#分表" class="headerlink" title="分表"></a>分表</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">namespace App\Models;</span><br><span class="line"></span><br><span class="line">use DB;</span><br><span class="line">use Schema;</span><br><span class="line">use Illuminate\Database\Eloquent\Model;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Logs</span> <span class="keyword">extends</span> <span class="title">Model</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    protected $guarded = [<span class="string">'id'</span>];</span><br><span class="line">    protected $table;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params">array $attributes = []</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        parent::__construct($attributes);</span><br><span class="line">        $<span class="keyword">this</span>-&gt;table = <span class="string">'log_'</span>.date(<span class="string">'Y'</span>);</span><br><span class="line">        <span class="keyword">if</span> (!Schema::hasTable($<span class="keyword">this</span>-&gt;table))</span><br><span class="line">        &#123;</span><br><span class="line">            DB::update(<span class="string">'create table '</span>.$<span class="keyword">this</span>-&gt;table.<span class="string">' like logs'</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">Logs::where(<span class="string">'uid'</span>,<span class="string">''</span>)-&gt;first();</span><br></pre></td></tr></table></figure>
<h3 id="sentry-升级"><a href="#sentry-升级" class="headerlink" title="sentry 升级"></a>sentry 升级</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">server &#123;</span><br><span class="line">    listen       <span class="number">80</span>;</span><br><span class="line">    server_name  track.example.com;</span><br><span class="line"></span><br><span class="line">    set_real_ip_from <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>;</span><br><span class="line">    real_ip_header X-Forwarded-For;</span><br><span class="line">    real_ip_recursive on;</span><br><span class="line"></span><br><span class="line">    location / &#123;</span><br><span class="line">        <span class="comment">// 添加这两行</span></span><br><span class="line">        default_type text/html; <span class="comment">// 设置 content-type 表示这是一个网页</span></span><br><span class="line">        return 202; # 返回 202 表示已经接收，但是并不处理</span><br><span class="line">        client_max_body_size    <span class="number">100</span>M;</span><br><span class="line">        proxy_set_header X-Real-IP  $remote_addr;</span><br><span class="line">        proxy_set_header Host-Real-IP  $http_host;</span><br><span class="line">        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</span><br><span class="line">        proxy_set_header X-Real-Pcol http;</span><br><span class="line">        proxy_pass http:<span class="comment">//localhost:10000;</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">使用这两行，就可以保证客户端正常请求了数据，但是我却把它给抛弃了。保证客户端的正常浏览。</span><br><span class="line">cd /data/</span><br><span class="line">cp -r onpremise onpremise2</span><br><span class="line">cd onpremise</span><br><span class="line">docker-compose down</span><br><span class="line">git pull</span><br><span class="line">git diff docker-compose.yml</span><br><span class="line">git checkout docker-compose.yml</span><br><span class="line">git pull</span><br><span class="line"><span class="keyword">export</span> SENTRY_IMAGE=<span class="string">'sentry:9.1.2'</span></span><br><span class="line">docker-compose build --pull</span><br><span class="line">docker-compose run --rm web upgrade</span><br><span class="line"></span><br><span class="line">docker-compose up -d</span><br><span class="line">https:<span class="comment">//learnku.com/articles/32569</span></span><br></pre></td></tr></table></figure>
<h3 id="基于雪花算法的-PHP-ID-生成器"><a href="#基于雪花算法的-PHP-ID-生成器" class="headerlink" title="基于雪花算法的 PHP ID 生成器"></a>基于雪花算法的 PHP ID 生成器</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line">https:<span class="comment">//github.com/godruoyi/php-snowflake</span></span><br><span class="line">$ composer <span class="built_in">require</span> godruoyi/php-snowflake -vvv</span><br><span class="line">$snowflake = <span class="keyword">new</span> \Godruoyi\Snowflake\Snowflake;</span><br><span class="line"></span><br><span class="line">$snowflake-&gt;id();</span><br><span class="line"><span class="comment">// 1537200202186752</span></span><br><span class="line">$snowflake = <span class="keyword">new</span> \Godruoyi\Snowflake\Snowflake($datacenterId, $workerId);</span><br><span class="line"></span><br><span class="line">$snowflake-&gt;id();</span><br><span class="line">$snowflake = <span class="keyword">new</span> \Godruoyi\Snowflake\Snowflake;</span><br><span class="line">$snowflake-&gt;setStartTimeStamp(strtotime(<span class="string">'2019-09-09'</span>)*<span class="number">1000</span>);</span><br><span class="line"></span><br><span class="line">$snowflake-&gt;id();</span><br><span class="line">集合laravel</span><br><span class="line"><span class="comment">// App\Providers\AppServiceProvider</span></span><br><span class="line"></span><br><span class="line">use Godruoyi\Snowflake\Snowflake;</span><br><span class="line">use Godruoyi\Snowflake\LaravelSequenceResolver;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">AppServiceProvider</span> <span class="keyword">extends</span> <span class="title">ServiceProvider</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * Register any application services.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * @return void</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">register</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;app-&gt;singleton(<span class="string">'snowflake'</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">            <span class="keyword">return</span> (<span class="keyword">new</span> Snowflake())</span><br><span class="line">                -&gt;setStartTimeStamp(strtotime(<span class="string">'2019-08-08'</span>)*<span class="number">1000</span>)</span><br><span class="line">                -&gt;setSequenceResolver(<span class="keyword">new</span> LaravelSequenceResolver(</span><br><span class="line">                    $<span class="keyword">this</span>-&gt;app-&gt;get(<span class="string">'cache'</span>)-&gt;store()</span><br><span class="line">                ));</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">$snowflake = <span class="keyword">new</span> \Godruoyi\Snowflake\Snowflake;</span><br><span class="line">$snowflake-&gt;setSequenceResolver(<span class="function"><span class="keyword">function</span> (<span class="params">$currentTime</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">static</span> $lastTime;</span><br><span class="line">    <span class="keyword">static</span> $sequence;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> ($lastTime == $currentTime) &#123;</span><br><span class="line">        ++$sequence;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    $lastTime = $currentTime;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> $sequence;</span><br><span class="line">&#125;)-&gt;id();</span><br><span class="line">https:<span class="comment">//learnku.com/articles/32575</span></span><br></pre></td></tr></table></figure>
<h3 id="内置web服务器"><a href="#内置web服务器" class="headerlink" title="内置web服务器"></a>内置web服务器</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">php -S localhost:<span class="number">8000</span> -t public/</span><br><span class="line">cd /home/baoguoxiao/www/php/demo</span><br><span class="line">php -S localhost:<span class="number">8000</span> router.php</span><br><span class="line">router.php 文件的代码</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 对URL进行解析，并获取请求的文件名</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">$uri = urldecode(parse_url($_SERVER[<span class="string">"REQUEST_URI"</span>], PHP_URL_PATH));</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 判断是否存在该文件，如果不存在，则直接继续加载入口文件</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">if</span> ($uri !== <span class="string">"/"</span> &amp;&amp; file_exists(__DIR__ . <span class="string">"$uri"</span>)) &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 加载入口文件</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">require_once <span class="string">"./index.php"</span>;</span><br><span class="line">vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 执行命令.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * @return int</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * @throws \Exception</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">handle</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">// 切换路径到 public 目录</span></span><br><span class="line">    chdir(public_path());</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 在命令台进行输出相关内容</span></span><br><span class="line">    $<span class="keyword">this</span>-&gt;line(<span class="string">"&lt;info&gt;Laravel development server started:&lt;/info&gt; &lt;http://&#123;$this-&gt;host()&#125;:&#123;$this-&gt;port()&#125;&gt;"</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 执行外部程序，并且 $status 为系统的返回状态</span></span><br><span class="line">    passthru($<span class="keyword">this</span>-&gt;serverCommand(), $status);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// $status 为0 表示执行正常, 为其他大于0的数字表示出现了错误，有可能是端口被抢占了，这个时候就会接着判断是否进行再次尝试</span></span><br><span class="line">    <span class="keyword">if</span> ($status &amp;&amp; $<span class="keyword">this</span>-&gt;canTryAnotherPort()) &#123;</span><br><span class="line">        <span class="comment">// 对绑定的端口号加1 默认是8000, 如果失败则重试端口号为8001，再次失败重试端口号为8002，以此类推。</span></span><br><span class="line">        $<span class="keyword">this</span>-&gt;portOffset += <span class="number">1</span>;</span><br><span class="line">        <span class="comment">// 再次调用此程序</span></span><br><span class="line">        <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;handle();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 返回状态值</span></span><br><span class="line">    <span class="keyword">return</span> $status;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 获取完整的 server 命令.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * @return string</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">protected <span class="function"><span class="keyword">function</span> <span class="title">serverCommand</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> sprintf(<span class="string">'%s -S %s:%s %s'</span>,</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 获取PHP可执行命令的路径</span></span><br><span class="line">        ProcessUtils::escapeArgument((<span class="keyword">new</span> PhpExecutableFinder)-&gt;find(<span class="literal">false</span>)),</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// 获取需要绑定的host</span></span><br><span class="line">        $<span class="keyword">this</span>-&gt;host(),</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 获取需要绑定的端口</span></span><br><span class="line">        $<span class="keyword">this</span>-&gt;port(),</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 对需要执行的参数进行转义处理。这里的 server 就是我们之前说的路由文件，它在项目的根路径下</span></span><br><span class="line">        ProcessUtils::escapeArgument(base_path(<span class="string">'server.php'</span>))</span><br><span class="line">    );</span><br><span class="line">&#125;</span><br><span class="line">对上面的命令进行翻译一下，实际上就是执行的</span><br><span class="line"></span><br><span class="line">cd ./public</span><br><span class="line">php -S <span class="number">0.0</span><span class="number">.0</span><span class="number">.0</span>:<span class="number">8000</span> ../server.php</span><br><span class="line">note:</span><br><span class="line"></span><br><span class="line">这里我们可以看到一个区别就是之前我自己写的代码，host 都是 localhost, 但是这里写的是 <span class="number">0.0</span><span class="number">.0</span><span class="number">.0</span>。这两个有什么区别呢？</span><br><span class="line"></span><br><span class="line">其实区别很简单，比如我之前写的 localhost 绑定的ip 是 <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>, 这个相当于一个回环地址，那么我们就只允许本机的IP进行访问。而 <span class="number">0.0</span><span class="number">.0</span><span class="number">.0</span>，则表示我们对ip不进行限制，所有的IP都可以进行访问。</span><br><span class="line">那我们接着再来看看项目根目录下面的server.php:</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Laravel - A PHP Framework For Web Artisans</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * @package  Laravel</span></span><br><span class="line"><span class="comment"> * @author   Taylor Otwell &lt;taylor@laravel.com&gt;</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line">$uri = urldecode(</span><br><span class="line">    parse_url($_SERVER[<span class="string">'REQUEST_URI'</span>], PHP_URL_PATH)</span><br><span class="line">);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 这个文件允许我们从内置 PHP web 服务器中模拟 Apache 的 "mod_rewrite" 功能.</span></span><br><span class="line"><span class="comment">// 这提供了一种测试 Laravel 应用程序的便捷方法,</span></span><br><span class="line"><span class="comment">// 而无需在此安装"真正的" web 服务器软件。</span></span><br><span class="line"><span class="keyword">if</span> ($uri !== <span class="string">'/'</span> &amp;&amp; file_exists(__DIR__.<span class="string">'/public'</span>.$uri)) &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">require_once __DIR__.<span class="string">'/public/index.php'</span>;</span><br><span class="line">https:<span class="comment">//github.com/mowangjuanzi/blog/blob/master/posts/2019.05.18-php_built_in_web_server.md</span></span><br></pre></td></tr></table></figure>
<h3 id="响应宏"><a href="#响应宏" class="headerlink" title="响应宏"></a>响应宏</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">在任意一个ServiceProvider的boot方法里（ResponseMacroServiceProvider），使用Response Facade注册</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">Response::macro(<span class="string">'success'</span>, <span class="function"><span class="keyword">function</span> (<span class="params">$data = [], $message = <span class="string">'success'</span></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">new</span> JsonResponse([</span><br><span class="line">        <span class="string">'code'</span> =&gt; <span class="number">0</span>,</span><br><span class="line">        <span class="string">'data'</span> =&gt; $data,</span><br><span class="line">        <span class="string">'message'</span> =&gt; $message</span><br><span class="line">    ], <span class="number">200</span>);</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">接下来， 你可以再任何地方使用它response()。</span><br><span class="line"></span><br><span class="line"><span class="comment">//UserController.php</span></span><br><span class="line"></span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">users</span>(<span class="params">UserRepository $userRepository</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> response()-&gt;success($userRepository-&gt;all(), <span class="string">'success'</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">注意，你只能通过response()这个全局方法或是app(<span class="string">'Illuminate\Routing\ResponseFactory'</span>)来使用它</span><br><span class="line"></span><br><span class="line">response()-&gt;success();<span class="comment">//OK</span></span><br><span class="line">app(<span class="string">'Illuminate\Routing\ResponseFactory'</span>)-&gt;success();<span class="comment">//OK</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//Response Facade</span></span><br><span class="line">Response::success();<span class="comment">//ok</span></span><br><span class="line"></span><br><span class="line">(<span class="keyword">new</span> \Illuminate\Http\Response)-&gt;success();<span class="comment">//Error</span></span><br><span class="line">https:<span class="comment">//godruoyi.com/posts/laravel-response-macro-principle</span></span><br></pre></td></tr></table></figure>
<h3 id="Intervention-Image-合成图片"><a href="#Intervention-Image-合成图片" class="headerlink" title="Intervention Image 合成图片"></a>Intervention Image 合成图片</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">use Intervention\Image\ImageManager;</span><br><span class="line"></span><br><span class="line">$manager = <span class="keyword">new</span> ImageManager(array(<span class="string">'driver'</span> =&gt; <span class="string">'imagick'</span>));</span><br><span class="line">use Intervention\Image\Facades\Image;</span><br><span class="line"></span><br><span class="line"><span class="comment">//或</span></span><br><span class="line">$manager = app(<span class="string">'image'</span>);</span><br><span class="line"><span class="comment">// $image = $manager-&gt;make($bg);</span></span><br><span class="line"><span class="comment">// $image = Image::make($bg);</span></span><br><span class="line"></span><br><span class="line">$image = app(<span class="string">'image'</span>)-&gt;make($bg);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 二维码图片</span></span><br><span class="line">$qrcodeImage = app(<span class="string">'image'</span>)-&gt;make($qrcodeurl)-&gt;resize(<span class="number">200</span>, <span class="number">200</span>);</span><br><span class="line"><span class="comment">// 重置 头像 大小</span></span><br><span class="line">$avatarImage  = app(<span class="string">'image'</span>)-&gt;make($httpClient-&gt;request(<span class="string">'GET'</span>, $avatarurl)-&gt;getBody())-&gt;resize(<span class="number">200</span>, <span class="number">200</span>);</span><br><span class="line"></span><br><span class="line">$image-&gt;text(<span class="string">'Nickname'</span>, <span class="number">376</span>, <span class="number">320</span>, <span class="function"><span class="keyword">function</span> (<span class="params">$font</span>) </span>&#123;</span><br><span class="line">    $font-&gt;file(public_path(<span class="string">'fonts/SimHei.ttf'</span>));</span><br><span class="line">    $font-&gt;size(<span class="number">40</span>);</span><br><span class="line">    $font-&gt;color(<span class="string">'#000000'</span>);</span><br><span class="line">    $font-&gt;align(<span class="string">'center'</span>);</span><br><span class="line">    $font-&gt;valign(<span class="string">'top'</span>);</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line">$image-&gt;insert($qrcodeImage, <span class="string">'bottom'</span>, <span class="number">0</span>, <span class="number">360</span>);</span><br><span class="line">$image-&gt;insert($avatarImage, <span class="string">'top'</span>, <span class="number">0</span>, <span class="number">105</span>);</span><br><span class="line">中文字体文件https:<span class="comment">//github.com/StellarCN/scp_zh/tree/master/fonts</span></span><br></pre></td></tr></table></figure>
<h3 id="nginx-配置多域名"><a href="#nginx-配置多域名" class="headerlink" title="nginx 配置多域名"></a>nginx 配置多域名</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">这个是精确匹配问题：</span><br><span class="line"></span><br><span class="line">nginx server_name 匹配不到时，默认取第一个 server &#123; &#125; (端口和 ip 一致)</span><br><span class="line"></span><br><span class="line">你项目中配置:</span><br><span class="line"></span><br><span class="line"><span class="number">1.</span> server_name www.test.com</span><br><span class="line"><span class="number">2.</span> server_name www.mytest.com</span><br><span class="line">访问 test.com/mytest.com 都找不到对应的 server_name (www.test.com != test.com , www.mytest.com != mytest.com)，所以就取第一个 server &#123; &#125; 匹配，所以均输出 test</span><br><span class="line"></span><br><span class="line">server_name mytest.com *.mytest.com</span><br><span class="line"></span><br><span class="line">https:<span class="comment">//learnku.com/laravel/t/32300</span></span><br></pre></td></tr></table></figure>
<h3 id="插入折半排序"><a href="#插入折半排序" class="headerlink" title="插入折半排序"></a>插入折半排序</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Person</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    public $id;</span><br><span class="line">    public $data;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">insertSort</span>(<span class="params">&amp;$data,$n</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">for</span> ($i=<span class="number">1</span>;$i&lt;$n;$i++)&#123;</span><br><span class="line">        $low = <span class="number">0</span>;</span><br><span class="line">        $high = $i<span class="number">-1</span>;</span><br><span class="line">        $temp = $data[$i];</span><br><span class="line">        <span class="keyword">while</span> ($low&lt;=$high)&#123;</span><br><span class="line">            $mid = floor(($low+$high)/<span class="number">2</span>);</span><br><span class="line">            <span class="keyword">if</span> ($data[$mid]-&gt;id&gt;$temp-&gt;id)&#123;</span><br><span class="line">                $high = $mid<span class="number">-1</span>;</span><br><span class="line">            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                $low = $mid+<span class="number">1</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">for</span> ($j=$i;$j&gt;$low;$j--)&#123;</span><br><span class="line">            $data[$j] = $data[$j<span class="number">-1</span>];</span><br><span class="line">        &#125;</span><br><span class="line">        $data[$low] = $temp;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">(<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line"></span><br><span class="line">    $person = <span class="keyword">new</span> Person();</span><br><span class="line">    $index = [<span class="string">'23'</span>=&gt;<span class="string">'勺颠颠'</span>,<span class="string">'65'</span>=&gt;<span class="string">'老油条'</span>,<span class="string">'21'</span>=&gt;<span class="string">'烧包谷'</span>,<span class="string">'9'</span>=&gt;<span class="string">'烧耳块'</span>,<span class="string">'4'</span>=&gt;<span class="string">'肥嘟嘟'</span>,<span class="string">'7'</span>=&gt;<span class="string">'霉戳戳'</span>,<span class="string">'32'</span>=&gt;<span class="string">'一坨肉'</span>,<span class="string">'6'</span>=&gt;<span class="string">'老扎哇'</span>];</span><br><span class="line">    $data = [];</span><br><span class="line">    foreach ($index <span class="keyword">as</span> $k=&gt;$v)&#123;</span><br><span class="line">        $obj = clone $person;</span><br><span class="line">        $obj-&gt;id = $k;</span><br><span class="line">        $obj-&gt;data = $v;</span><br><span class="line">        $data[] = $obj;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    insertSort($data,<span class="number">8</span>);</span><br><span class="line">    print_r($data);</span><br><span class="line"></span><br><span class="line">&#125;)(); </span><br><span class="line">https:<span class="comment">//learnku.com/articles/32691</span></span><br></pre></td></tr></table></figure>
<h3 id="sql拼接"><a href="#sql拼接" class="headerlink" title="sql拼接"></a>sql拼接</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$statusInStr = implode(<span class="string">','</span>, <span class="string">'1,2,3'</span>);</span><br><span class="line">字符串</span><br><span class="line">$statusInStr = <span class="string">"'"</span>.implode(<span class="string">"','"</span>, [<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>]).<span class="string">"'"</span>;<span class="comment">//'1','2','3'</span></span><br><span class="line"><span class="string">"select * from table where status in (&#123;$statusInStr&#125;)"</span><span class="comment">//select * from table where status in ('1','2','3')</span></span><br></pre></td></tr></table></figure>
<h3 id="x-www-form-urlencoded-与-multipart-form-data"><a href="#x-www-form-urlencoded-与-multipart-form-data" class="headerlink" title="x-www-form-urlencoded 与 multipart/form-data"></a>x-www-form-urlencoded 与 multipart/form-data</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line">x-www-form-urlencoded，表单默认的 Content-type 类型，支持 ASCII-text 文本内容</span><br><span class="line">multipart/form-data，允许提交表单包含： files，non-ASCII-text，Binary 类型数据</span><br><span class="line">当表单使用 application/x-www-form-urlencoded 时，需要对参数进行 urlencode 编码和序列化</span><br><span class="line"></span><br><span class="line">如，表单提交参数（key-value）为：</span><br><span class="line"></span><br><span class="line">param1:website</span><br><span class="line">param2:https:<span class="comment">//www.google.com</span></span><br><span class="line">经过 urlencode 编码后：</span><br><span class="line"></span><br><span class="line">param1:website</span><br><span class="line">param2:https%<span class="number">3</span>A%<span class="number">2</span>F%<span class="number">2</span>Fwww.google.com</span><br><span class="line">再经过序列化，得到结果</span><br><span class="line"></span><br><span class="line">param1=website&amp;param2=https%<span class="number">3</span>A%<span class="number">2</span>F%<span class="number">2</span>Fwww.google.com</span><br><span class="line">multipart/form-data</span><br><span class="line"></span><br><span class="line">一个 multipart/form-data 消息体，包含多个块组成，每个块代表一个有效的表单控件，并使用 boundary 的字符串分割：</span><br><span class="line"></span><br><span class="line">第一部分，Content-Disposition: form-data 参数名称，如，name=<span class="string">"my_control</span></span><br><span class="line"><span class="string">第二部分，Content-Type: text/plain，Content-Type: image/png</span></span><br><span class="line"><span class="string">第三部分，消息内容</span></span><br><span class="line"><span class="string">例如表单：</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">&lt;FORM action="</span>http:<span class="comment">//server.com/cgi/handle"</span></span><br><span class="line">       enctype=<span class="string">"multipart/form-data"</span></span><br><span class="line">       method=<span class="string">"post"</span>&gt;</span><br><span class="line">   &lt;P&gt;</span><br><span class="line">   What is your name? &lt;INPUT type="text" name="submit-name"&gt;&lt;BR&gt;</span><br><span class="line">   What files are you sending? &lt;INPUT type="file" name="files"&gt;&lt;BR&gt;</span><br><span class="line">   &lt;INPUT type="submit" value="Send"&gt;</span><br><span class="line">   &lt;INPUT type="reset"&gt;</span><br><span class="line">&lt;/FORM&gt;</span><br><span class="line">假设，submit-name 输入 Larry 文本，files 选择文件 file1.txt</span><br><span class="line"></span><br><span class="line">Content-Type: multipart/form-data; boundary=AaB03x</span><br><span class="line"></span><br><span class="line">--AaB03x</span><br><span class="line">Content-Disposition: form-data; name="submit-name"</span><br><span class="line"></span><br><span class="line">Larry</span><br><span class="line">--AaB03x</span><br><span class="line">Content-Disposition: form-data; name="files"; filename="file1.txt"</span><br><span class="line">Content-Type: text/plain</span><br><span class="line"></span><br><span class="line">... contents of file1.txt ...</span><br><span class="line">--AaB03x--</span><br><span class="line">https://learnku.com/articles/32812</span><br></pre></td></tr></table></figure>
<h3 id="Model-setAttribute"><a href="#Model-setAttribute" class="headerlink" title="Model::setAttribute()"></a>Model::setAttribute()</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">App\GameWork::create([</span><br><span class="line">    <span class="string">"task_id"</span> =&gt; <span class="string">"23571"</span>,</span><br><span class="line">    <span class="string">"type"</span> =&gt; <span class="number">2</span>,</span><br><span class="line">    <span class="string">"take_time"</span> =&gt; <span class="string">"1563085291"</span>,</span><br><span class="line">    <span class="string">"send_time"</span> =&gt; <span class="number">1563093004</span>,</span><br><span class="line">    <span class="string">"chufa"</span> =&gt; <span class="number">10</span>,</span><br><span class="line">    <span class="string">"worker"</span> =&gt; <span class="number">0</span>,</span><br><span class="line">    <span class="string">"work_time"</span> =&gt; <span class="number">0</span>,</span><br><span class="line">    <span class="string">"log"</span> =&gt; <span class="string">"超时"</span>,</span><br><span class="line">    <span class="string">"uid"</span> =&gt; <span class="number">271</span>,</span><br><span class="line">    <span class="string">"game_id"</span> =&gt; <span class="number">3532054</span>,</span><br><span class="line">    <span class="string">"buyer_id"</span> =&gt; <span class="number">64</span></span><br><span class="line">]);</span><br><span class="line">结果提示我</span><br><span class="line"></span><br><span class="line"><span class="built_in">TypeError</span>: Too few <span class="built_in">arguments</span> to <span class="function"><span class="keyword">function</span> <span class="title">Illuminate</span>/<span class="title">Database</span>/<span class="title">Eloquent</span>/<span class="title">Model</span>::<span class="title">setAttribute</span>(<span class="params"></span>), 1 <span class="title">passed</span> <span class="title">in</span> /<span class="title">Library</span>/<span class="title">WebServer</span>/<span class="title">Documents</span>/<span class="title">api</span>/<span class="title">vendor</span>/<span class="title">laravel</span>/<span class="title">framework</span>/<span class="title">src</span>/<span class="title">Illuminate</span>/<span class="title">Database</span>/<span class="title">Eloquent</span>/<span class="title">Concerns</span>/<span class="title">HasAttributes</span>.<span class="title">php</span> <span class="title">on</span> <span class="title">line</span> 617 <span class="title">and</span> <span class="title">exactly</span> 2 <span class="title">expected</span></span></span><br><span class="line"><span class="function">把自增关闭就好了，<span class="title">laravel</span> 默认是所有表都有个自增 <span class="title">ID</span>，我的表不需要</span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"><span class="title">public</span> <span class="title">$incrementing</span> = <span class="title">false</span>;</span></span><br><span class="line"><span class="function"><span class="title">https</span>://<span class="title">learnku</span>.<span class="title">com</span>/<span class="title">laravel</span>/<span class="title">t</span>/31164</span></span><br></pre></td></tr></table></figure>
<h3 id="处理unicode解码"><a href="#处理unicode解码" class="headerlink" title="处理unicode解码"></a>处理unicode解码</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// change unicode to unt-8</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">replace_unicode_escape_sequence</span>(<span class="params">$match</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> mb_convert_encoding(pack(<span class="string">'H*'</span>, $match[<span class="number">1</span>]), <span class="string">'UTF-8'</span>, <span class="string">'UCS-2BE'</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">unicode_decode</span>(<span class="params">$str</span>) </span>&#123;</span><br><span class="line"> <span class="keyword">return</span> preg_replace_callback(<span class="string">'/u([0-9a-f]&#123;4&#125;)/i'</span>, <span class="string">'replace_unicode_escape_sequence'</span>, $str); </span><br><span class="line">&#125;</span><br><span class="line">$str = unicode_decode(<span class="string">'&#123;"u5173u952eu8bcd":[&#123;"","key":"u767eu5ea6"&#125;]&#125;'</span>);</span><br><span class="line"><span class="comment">//&#123;"关键词":[&#123;"","key":"百度"&#125;]&#125;</span></span><br><span class="line">如果编码是 \u5173\u952e\u8bcd 正则改为/\u([<span class="number">0</span><span class="number">-9</span>a-f]&#123;<span class="number">4</span>&#125;)/i 即可</span><br><span class="line">http:<span class="comment">//cuihuan.net/2015/11/28/php%20%E5%A4%84%E7%90%86unicode%E8%A7%A3%E7%A0%81/</span></span><br></pre></td></tr></table></figure>
<h3 id="恶意提交攻击"><a href="#恶意提交攻击" class="headerlink" title="恶意提交攻击"></a>恶意提交攻击</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line"> <span class="comment">// check 环境ip</span></span><br><span class="line">    <span class="keyword">if</span> (!$<span class="keyword">this</span>-&gt;isWhiteList($ip)) &#123;</span><br><span class="line">        $echo_str = <span class="string">"提交过于频繁,请稍后再试！"</span>;</span><br><span class="line">        <span class="comment">// 构建ip的时间栈数据</span></span><br><span class="line">        <span class="keyword">if</span> (!is_array($_SESSION[$ip])) &#123;</span><br><span class="line">            $_SESSION[$ip] = array();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span> (isset($_SESSION[$ip][<span class="number">0</span>])) &#123;</span><br><span class="line">            $_SESSION[$ip][] = time();</span><br><span class="line">            <span class="comment">// session 保存时间为6小时。清理session</span></span><br><span class="line">            $post_interval_first = time() - $_SESSION[$ip][<span class="number">0</span>];</span><br><span class="line">            <span class="keyword">if</span> ($post_interval_first &gt; <span class="number">21600</span>) &#123;</span><br><span class="line">                $_SESSION[$ip] = array();</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="comment">// 两次提交小于1s，禁止提交</span></span><br><span class="line">            $post_interval_pre = time() - $_SESSION[$ip][count($_SESSION[$ip]) - <span class="number">3</span>];</span><br><span class="line">            <span class="keyword">if</span> ($post_interval_pre &lt; <span class="number">1</span>) &#123;</span><br><span class="line">                echo $echo_str;</span><br><span class="line">                exit;</span><br><span class="line">            &#125;;</span><br><span class="line">            <span class="comment">// 您在10s内已经提交了3请求，禁止提交</span></span><br><span class="line">            $post_interval_third = time() - $_SESSION[$ip][count($_SESSION[$ip]) - <span class="number">3</span>];</span><br><span class="line">            <span class="keyword">if</span> (isset($_SESSION[$ip][<span class="number">3</span>]) &amp;&amp; ($post_interval_third &lt; <span class="number">10</span>)) &#123;</span><br><span class="line">                echo $echo_str;</span><br><span class="line">                exit;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="comment">// 您在1分钟期间已经提交了5请求，禁止提交</span></span><br><span class="line">            $post_interval_fifth = time() - $_SESSION[$ip][count($_SESSION[$ip]) - <span class="number">3</span>];</span><br><span class="line">            <span class="keyword">if</span> (isset($_SESSION[$ip][<span class="number">5</span>]) &amp;&amp; ($post_interval_fifth &lt; <span class="number">60</span>)) &#123;</span><br><span class="line">                echo $echo_str;</span><br><span class="line">                exit;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="comment">// 6小时内提交10次，禁止提交</span></span><br><span class="line">            <span class="keyword">if</span> (isset($_SESSION[$ip][<span class="number">10</span>])) &#123;</span><br><span class="line">                echo $echo_str;</span><br><span class="line">                exit;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            $_SESSION[$ip][] = time();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">isWhiteList</span>(<span class="params">$ip</span>)</span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 内网ip默认全部存在于白名单中</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="keyword">if</span>(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 是否在写死的whitelist 里面</span></span><br><span class="line">    <span class="keyword">return</span> in_array($ip,$<span class="keyword">this</span>-&gt;_WHTTE_LIST);</span><br><span class="line">&#125;</span><br><span class="line">http:<span class="comment">//cuihuan.net/2016/01/07/%E6%9C%BA%E5%99%A8%E5%A4%9A%E6%AC%A1%E6%81%B6%E6%84%8F%E6%8F%90%E4%BA%A4%E6%94%BB%E5%87%BB/</span></span><br></pre></td></tr></table></figure>
<h3 id="切换镜像"><a href="#切换镜像" class="headerlink" title="切换镜像"></a>切换镜像</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">composer config -g repo.packagist composer https:<span class="comment">//mirrors.aliyun.com/composer/</span></span><br><span class="line">composer update -vvv</span><br><span class="line"></span><br><span class="line">执行成功以后，打开 composer.lock, 发现文件中的链接依旧是 laravel-china 的地址</span><br><span class="line"></span><br><span class="line">删掉 lock，再 install，会安装最新的包，在生产环境这样，可能会搞出事来，，</span><br><span class="line"></span><br><span class="line">composer update nothing 直接这样，就可以只更新 lock 文件里的源</span><br></pre></td></tr></table></figure>
<h3 id="composer-Failed-to-execute-unzip"><a href="#composer-Failed-to-execute-unzip" class="headerlink" title="composer Failed to execute unzip"></a>composer Failed to execute unzip</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"> composer 多线程下载的扩展包（hirak/prestissimo），因为是全局安装的，其原理就是下到缓存，然后以后全部都走缓存安装。所以我第一件事 先全局卸载掉它</span><br><span class="line"></span><br><span class="line">composer global remove hirak/prestissimo</span><br><span class="line">然后清空当前 composer 的缓存</span><br><span class="line"></span><br><span class="line">composer clear-cache</span><br><span class="line">然后使用 laravel <span class="keyword">new</span> blog， 你会发现没有报错了。</span><br><span class="line">https:<span class="comment">//learnku.com/articles/32898</span></span><br></pre></td></tr></table></figure>
<h3 id="sentry"><a href="#sentry" class="headerlink" title="sentry"></a>sentry</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">$ git clone https:<span class="comment">//github.com/getsentry/onpremise.git</span></span><br><span class="line">$ cd onpremise</span><br><span class="line">$ ./install.sh</span><br><span class="line">$ docker-compose up -d</span><br><span class="line"></span><br><span class="line">在目录下的 docker-compose.yml 添加配置：</span><br><span class="line"></span><br><span class="line">SENTRY_EMAIL_HOST: smtp.exmail.qq.com</span><br><span class="line">SENTRY_EMAIL_USER: 你的邮箱地址</span><br><span class="line">SENTRY_EMAIL_EMAIL: 你的邮箱地址</span><br><span class="line">SENTRY_EMAIL_PASSWORD: 授权码</span><br><span class="line">SENTRY_EMAIL_USE_TLS: <span class="string">'true'</span></span><br><span class="line">SENTRY_EMAIL_PORT: <span class="number">587</span></span><br><span class="line">重启 sentry 服务</span><br><span class="line"></span><br><span class="line">docker-compose down &amp;&amp; docker-compose up -d</span><br></pre></td></tr></table></figure>
<h3 id="抽离-vendor"><a href="#抽离-vendor" class="headerlink" title="抽离 vendor"></a>抽离 vendor</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">在 bootstrap 注册 autoload 就可以了。</span><br><span class="line">./bootstrap/app.php</span><br><span class="line"></span><br><span class="line">&lt;?php</span><br><span class="line">require_once __DIR__ . <span class="string">'/../vendor/autoload.php'</span>;</span><br><span class="line"></span><br><span class="line">$autoload = <span class="keyword">new</span> Composer\Autoload\ClassLoader();</span><br><span class="line">$autoload-&gt;addPsr4(<span class="string">'App\\'</span>, <span class="string">"../app/"</span>);</span><br><span class="line">$autoload-&gt;addClassMap([</span><br><span class="line">    <span class="string">"database/"</span>,</span><br><span class="line">    <span class="string">"tests/"</span></span><br><span class="line">]);</span><br><span class="line">$autoload-&gt;register();</span><br><span class="line">https:<span class="comment">//learnku.com/laravel/t/32840</span></span><br></pre></td></tr></table></figure>
<h3 id="dd-函数"><a href="#dd-函数" class="headerlink" title="dd 函数"></a>dd 函数</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">dd</span>(<span class="params">...$args</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        header(<span class="string">'Access-Control-Allow-Origin: *'</span>);</span><br><span class="line">        header(<span class="string">'Access-Control-Allow-Methods: *'</span>);</span><br><span class="line">        header(<span class="string">'Access-Control-Allow-Headers: *'</span>);</span><br><span class="line">        http_response_code(<span class="number">500</span>);</span><br><span class="line"> </span><br><span class="line">        foreach ($args <span class="keyword">as</span> $x) &#123;</span><br><span class="line">            (<span class="keyword">new</span> Illuminate\Support\Debug\Dumper)-&gt;dump($x);</span><br><span class="line">        &#125;</span><br><span class="line"> </span><br><span class="line">        die(<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
<h3 id="listen-sql"><a href="#listen-sql" class="headerlink" title="listen sql"></a>listen sql</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">\DB::listen(<span class="function"><span class="keyword">function</span> (<span class="params">QueryExecuted $sql</span>) </span>&#123;</span><br><span class="line">     \Log::info($sql-&gt;sql);</span><br><span class="line">     \Log::info((<span class="keyword">new</span> \Exception())-&gt;getTraceAsString());</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<h3 id="模型事件-updated"><a href="#模型事件-updated" class="headerlink" title="模型事件 updated"></a>模型事件 updated</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">只有 $sku-&gt;&#123;attribute&#125; != $sku-&gt;getOriginal(&#123;attribute&#125;) 不一致的时候才会触发</span><br><span class="line">　　getDirty() 不为空的时候才触发, 而且不会比较数据类型(判断是否 dirty 使用的是 == 而不是 ===)</span><br><span class="line"></span><br><span class="line">直接 app(Model::<span class="class"><span class="keyword">class</span>)-&gt;<span class="title">where</span>()-&gt;<span class="title">update</span>() 不会触发</span></span><br><span class="line"><span class="class">　　$<span class="title">sku</span> </span>= app(Sku::<span class="class"><span class="keyword">class</span>), $<span class="title">sku</span>-&gt;<span class="title">has_stock</span> </span>= <span class="number">1</span>; $sku-&gt;save() 这样才会触发</span><br><span class="line"></span><br><span class="line">这是因为，使用 app(Model::<span class="class"><span class="keyword">class</span>)-&gt;<span class="title">where</span>()-&gt;<span class="title">update</span>() 的时候，调用的是 <span class="title">Query</span>/<span class="title">Builder</span> 的 <span class="title">update</span> 方法，这里面是没法触发 <span class="title">update</span> 事件的。</span></span><br><span class="line"><span class="class"></span></span><br><span class="line"><span class="class">使用 $<span class="title">sku</span> </span>= app(Sku::<span class="class"><span class="keyword">class</span>), $<span class="title">sku</span>-&gt;<span class="title">has_stock</span> </span>= <span class="number">1</span>; $sku-&gt;save() 的时候，使用的 update 方法是 Eloquent/Model 里面的 update 方法。</span><br><span class="line">https:<span class="comment">//blog.baiguiren.com/2019/04/22/laravel/Laravel%20%E6%A8%A1%E5%9E%8B%E4%BA%8B%E4%BB%B6%20updated%20%E8%A7%A6%E5%8F%91%E6%9D%A1%E4%BB%B6/</span></span><br></pre></td></tr></table></figure>
<h3 id="获取所有-collection"><a href="#获取所有-collection" class="headerlink" title="获取所有 collection"></a>获取所有 collection</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">foreach (\DB::connection(<span class="string">'xxx'</span>)-&gt;getMongoDB()-&gt;listCollections() <span class="keyword">as</span> $collection) &#123;</span><br><span class="line">    echo $collection-&gt;getName() . PHP_EOL;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="获取带参数的-sql-语句"><a href="#获取带参数的-sql-语句" class="headerlink" title="获取带参数的 sql 语句"></a>获取带参数的 sql 语句</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">DB::table(<span class="string">'users'</span>)-&gt;where(<span class="string">'id'</span>, <span class="number">1</span>)-&gt;toSql();</span><br><span class="line">select * <span class="keyword">from</span> <span class="string">`users`</span> where <span class="string">`id`</span> = ?</span><br><span class="line">$builder = DB::table(<span class="string">'users'</span>)-&gt;where(<span class="string">'id'</span>, <span class="number">1</span>);</span><br><span class="line">$bindings = $builder-&gt;getBindings();</span><br><span class="line">$sql = str_replace(<span class="string">'?'</span>, <span class="string">'%s'</span>, $builder-&gt;toSql());</span><br><span class="line">$sql = sprintf($sql, ...$bindings);</span><br><span class="line">select * <span class="keyword">from</span> <span class="string">`tb_user`</span> where <span class="string">`id`</span> = <span class="number">1</span></span><br><span class="line"></span><br><span class="line">\Illuminate\Database\Query\Builder::macro(<span class="string">'sql'</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">    $bindings = $<span class="keyword">this</span>-&gt;getBindings();</span><br><span class="line">    $sql = str_replace(<span class="string">'?'</span>, <span class="string">'%s'</span>, $<span class="keyword">this</span>-&gt;toSql());</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">return</span> sprintf($sql, ...$bindings);</span><br><span class="line">&#125;);</span><br><span class="line">dd(DB::table(<span class="string">'users'</span>)-&gt;where(<span class="string">'id'</span>, <span class="number">1</span>)-&gt;sql());</span><br><span class="line"></span><br><span class="line">https:<span class="comment">//blog.baiguiren.com/2018/06/27/laravel/Laravel%20%E4%B8%AD%E7%9A%84%20toSql%20%E8%8E%B7%E5%8F%96%E5%B8%A6%E5%8F%82%E6%95%B0%E7%9A%84%20sql%20%E8%AF%AD%E5%8F%A5/</span></span><br></pre></td></tr></table></figure>
<h3 id="命令行输出进度条"><a href="#命令行输出进度条" class="headerlink" title="命令行输出进度条"></a>命令行输出进度条</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">namespace App\Commands;</span><br><span class="line"> </span><br><span class="line">use Illuminate\Console\Command;</span><br><span class="line">use Symfony\Component\Console\Helper\ProgressBar;</span><br><span class="line">use Symfony\Component\Console\Output\ConsoleOutput;</span><br><span class="line"> </span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Test</span> <span class="keyword">extends</span> <span class="title">Command</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    protected $signature = <span class="string">'test'</span>;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * Execute the command.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * @return void</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">handle</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">//</span></span><br><span class="line">        $output = <span class="keyword">new</span> ConsoleOutput();</span><br><span class="line">        $progressBar = <span class="keyword">new</span> ProgressBar($output, <span class="number">1000</span>);</span><br><span class="line">        $progressBar-&gt;setFormat(<span class="string">"   %elapsed:6s%/%estimated:-6s%   内存消耗: %memory:6s%\n%current%/%max% [%bar%] %percent:3s%%"</span>);</span><br><span class="line"> </span><br><span class="line">        foreach (range(<span class="number">1</span>, <span class="number">1000</span>) <span class="keyword">as</span> $_) &#123;</span><br><span class="line">            usleep(<span class="number">5000</span>);</span><br><span class="line">            $progressBar-&gt;advance();</span><br><span class="line">        &#125;</span><br><span class="line"> </span><br><span class="line">        $progressBar-&gt;finish();</span><br><span class="line">        echo <span class="string">"\n"</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">$progressBar-&gt;start();</span><br><span class="line">print <span class="string">"\n"</span>;</span><br><span class="line">$progressBar-&gt;start();</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">$progressBar-&gt;setFormat(<span class="string">"已处理数量: %count%"</span>);  <span class="comment">// 这里是一个占位符，可以和进度条写在一起</span></span><br><span class="line">$progressBar-&gt;setMessage($count, <span class="string">'count'</span>); <span class="comment">// 使用 `$count` 替换输出内容中的 "%$count%"</span></span><br></pre></td></tr></table></figure>
<h3 id="with-通过闭包筛选"><a href="#with-通过闭包筛选" class="headerlink" title="with 通过闭包筛选"></a>with 通过闭包筛选</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">User</span> <span class="keyword">extends</span> <span class="title">Model</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">profile</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;hasOne(<span class="string">'App\UserProfile'</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">App\User::<span class="keyword">with</span>([</span><br><span class="line">    <span class="string">'profile'</span> =&gt; <span class="function"><span class="keyword">function</span>(<span class="params">$query</span>) </span>&#123;</span><br><span class="line">        $query-&gt;select([<span class="string">'id'</span>]);</span><br><span class="line">    &#125;</span><br><span class="line">])</span><br><span class="line">-&gt;find(<span class="number">4</span>)</span><br><span class="line">-&gt;toArray();</span><br><span class="line">即使数据库有记录，sql 也记录了对应的查询语句，但是 profile 关联却是空的</span><br><span class="line">App\User::<span class="keyword">with</span>([</span><br><span class="line">    <span class="string">'profile'</span> =&gt; <span class="function"><span class="keyword">function</span>(<span class="params">$query</span>) </span>&#123;</span><br><span class="line">        $query-&gt;select([<span class="string">'id'</span>, <span class="string">'user_id'</span>]); <span class="comment">// 多了 user_id</span></span><br><span class="line">    &#125;</span><br><span class="line">])</span><br><span class="line">-&gt;find(<span class="number">4</span>)</span><br><span class="line">-&gt;toArray();</span><br><span class="line">可以查找到正确的 profile 了</span><br><span class="line">hasMany 方法默认第二第三个参数其实就是这两个集合建立关联的关键，第三个参数 user_id、第四个参数 id；这样一来我们就可以通过比较 Profile 的 user_id 和 User 里面的 id，如果相等，则这个 Profile 是属于这个 User 的，我们就把该 Profile 放进 User 的 profile 关联中，最后就得到我们想要的结果了</span><br><span class="line">Laravel 先查询主要的数据(不带 <span class="keyword">with</span>)，查询完了之后，取出其中的 id 列数组(不一定都是id啊，只是举个例子)，将这个数组作为条件去查找关联，有多少个关联就会再去查找多少次，查找完关联之后通过得到的结果的主键和关联数据的外键比对，相等则建立关联。</span><br><span class="line"></span><br><span class="line">总结：在关联筛选 field 的时候，也必须要把关联的外键写进去，否则，即使产生了正确的 sql 语句，但是它们建立不了关联，通过 $user-&gt;profile 得到的还是一个空集合。</span><br><span class="line">https:<span class="comment">//blog.baiguiren.com/2018/01/06/laravel/Laravel%205.1%20Eloquent%20with%20%E9%80%9A%E8%BF%87%E9%97%AD%E5%8C%85%E7%AD%9B%E9%80%89%E7%89%B9%E5%AE%9A%20field%20%E5%BE%97%E4%B8%8D%E5%88%B0%E7%BB%93%E6%9E%9C%E7%9A%84%E9%97%AE%E9%A2%98/</span></span><br></pre></td></tr></table></figure>
<h3 id="Laravel-cookie加密解密"><a href="#Laravel-cookie加密解密" class="headerlink" title="Laravel cookie加密解密"></a>Laravel cookie加密解密</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">$data = <span class="string">'laravel'</span>;</span><br><span class="line">$iv = random_bytes(<span class="number">16</span>);</span><br><span class="line">$key = <span class="string">'this is key'</span>;</span><br><span class="line"> </span><br><span class="line">$encrypt = openssl_encrypt($data, <span class="string">'AES-256-CBC'</span>, $key, <span class="number">0</span>, $iv);</span><br><span class="line"> </span><br><span class="line">var_dump($encrypt);</span><br><span class="line">var_dump(openssl_decrypt($encrypt, <span class="string">'AES-256-CBC'</span>, $key, <span class="number">0</span>, $iv));</span><br><span class="line">Laravel 中的话，key 就是 .env 配置文件里面的 APP_KEY，除了 key 还有两个变化的参数就是 加密、解密的数据以及 iv。</span><br><span class="line"></span><br><span class="line">也就是说，如果我们需要加密 cookie 的话，我们至少得保存下 加密后的数据以及 iv</span><br><span class="line">虽然每次请求 cookie 都会发生变化，但是实际数据是没有变的，发生变化只是因为用来加密的 iv 变了(使用 random_bytes 方法生成)。</span><br><span class="line"></span><br><span class="line">由于 iv 每次都变化，所以需要把 iv 也一同返回给浏览器，加上验证数据合法性的 mac，最后返回的就是下面的数组的 json 编码后在 base64 编码的数据：</span><br><span class="line">[</span><br><span class="line">   <span class="string">'iv'</span> =&gt; random_bytes(<span class="number">16</span>), <span class="comment">// 16位随机字节串</span></span><br><span class="line">   <span class="string">'value'</span> =&gt; <span class="string">'xxxx...'</span>,    <span class="comment">// 加密后的数据</span></span><br><span class="line">   <span class="string">'mac'</span> =&gt; <span class="string">'xxx...'</span>   <span class="comment">// 后续请求验证数据合法性的字符串</span></span><br><span class="line">]https:<span class="comment">//blog.baiguiren.com/2018/01/11/laravel/Laravel%20cookie%20%E5%8A%A0%E5%AF%86%E8%A7%A3%E5%AF%86%E5%8E%9F%E7%90%86/</span></span><br></pre></td></tr></table></figure>
<h3 id="Eloquent-Builder-添加自定义方法"><a href="#Eloquent-Builder-添加自定义方法" class="headerlink" title="Eloquent Builder 添加自定义方法"></a>Eloquent Builder 添加自定义方法</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">\Illuminate\Database\Query\Builder\Builder::macro(<span class="string">'active'</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;where(<span class="string">'status'</span>, <span class="number">1</span>);</span><br><span class="line">&#125;);</span><br><span class="line">DB::table(xxx)-&gt;active()-&gt;get();</span><br><span class="line"></span><br><span class="line">\App\Model\User::active()-&gt;first();</span><br><span class="line">在 app/Providers 下面新建一个 Provider，把 macro 调用放到 Provider 的 register 方法中</span><br><span class="line">namespace App\Providers;</span><br><span class="line"> </span><br><span class="line">use Illuminate\Database\Query\Builder;</span><br><span class="line">use Illuminate\Support\ServiceProvider;</span><br><span class="line"> </span><br><span class="line"><span class="comment">/** @mixin \Illuminate\Database\Eloquent\Builder */</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">DatabaseServiceProvider</span> <span class="keyword">extends</span> <span class="title">ServiceProvider</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * Register any application services.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * @return void</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">register</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        Builder::macro(<span class="string">'active'</span>, <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">            <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;where(<span class="string">'status'</span>, <span class="number">1</span>);</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">加了 Providers 之后还要在 config/app.php 中配置这个 Provider。</span><br></pre></td></tr></table></figure>
<h3 id="修改模型对象的某个属性"><a href="#修改模型对象的某个属性" class="headerlink" title="修改模型对象的某个属性"></a>修改模型对象的某个属性</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">$user = <span class="keyword">new</span> User;</span><br><span class="line">$user-&gt;age = <span class="number">26</span>;</span><br><span class="line">dd($user-&gt;toArray(), $user-&gt;getAttributes()); <span class="comment">// ['age' =&gt; 26], ['age' =&gt; 26]</span></span><br><span class="line"></span><br><span class="line">我们想修改里面属性的时候比如 $user-&gt;info[<span class="string">'job'</span>] = <span class="string">'PHP'</span>;，实际上等同于：</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line">$user-&gt;__get(<span class="string">'info'</span>)[<span class="string">'job'</span>] = <span class="string">'PHP'</span>;</span><br><span class="line">也就是说，等同于：</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line">$temp = $user-&gt;__get(<span class="string">'info'</span>);</span><br><span class="line">$temp[<span class="string">'job'</span>] = <span class="string">'PHP'</span>;</span><br><span class="line">也就是说，我们在设置有层级的属性的时候，中间产生了临时变量。</span><br><span class="line"></span><br><span class="line">假设大家知道了值传递、引用传递的区别。</span><br><span class="line"></span><br><span class="line">这个时候问题就来了，如果这个 $user-&gt;info 是一个数组，我们最终修改的是一个临时数组，而 $user-&gt;info 还是不变。这个时候就报错了，因为这个修改是完全没有意义的。</span><br><span class="line"></span><br><span class="line">而如果 $user-&gt;info 是一个对象的时候，我们临时变量也是一个对象，而对象是通过引用传递的，我们修改了这个对象的时候，实际上也修改了 $user-&gt;info，因为这个临时变量指向了原始对象。</span><br><span class="line"></span><br><span class="line">$user = app(User::<span class="class"><span class="keyword">class</span>)</span>;</span><br><span class="line"></span><br><span class="line">$user-&gt;infoObj = <span class="keyword">new</span> stdClass;</span><br><span class="line">$user-&gt;infoObj-&gt;age = <span class="number">26</span>;</span><br><span class="line">$user-&gt;infoObj-&gt;job = <span class="string">'PHP'</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// dd($user-&gt;toArray());</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// Indirect modification of overloaded property User::$info has no effect</span></span><br><span class="line">$user-&gt;info = [</span><br><span class="line">    <span class="string">'age'</span> =&gt; <span class="number">26</span>,</span><br><span class="line">];</span><br><span class="line">$user-&gt;info[<span class="string">'job'</span>] = <span class="string">'PHP'</span>;</span><br><span class="line">https:<span class="comment">//blog.baiguiren.com/2018/07/05/laravel/Laravel%20Model%20-%20Indirect%20modification%20of%20overloaded%20property/</span></span><br></pre></td></tr></table></figure>
<h3 id="laravel技巧"><a href="#laravel技巧" class="headerlink" title="laravel技巧"></a>laravel技巧</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line">使用一次查询代替多次查询AdminUser::<span class="keyword">with</span>(<span class="string">'admin_user_info'</span>)-&gt;where(<span class="string">'id'</span>, <span class="string">'&gt;'</span>, <span class="number">1</span>)-&gt;get();</span><br><span class="line">$products = \DB::table(<span class="string">'product'</span>)-&gt;where(<span class="string">'category_id'</span>, <span class="number">1</span>)-&gt;paginate();</span><br><span class="line">$product_ids = $products-&gt;pluck(<span class="string">'id'</span>)-&gt;toArray(); <span class="comment">// 获取所有 id , 下面第二点有说到这个用法&lt;br&gt;</span></span><br><span class="line">$some_other_infos = \DB::table(<span class="string">'some_other_info'</span>) <span class="comment">// 根据 id 数组一次查询所有关联数据</span></span><br><span class="line">    -&gt;whereIn(<span class="string">'product_id'</span>, $product_ids)</span><br><span class="line">    -&gt;get(); </span><br><span class="line">$some_other_infos = array_column($some_other_infos, <span class="literal">null</span>, <span class="string">'product_id'</span>); <span class="comment">// 使用 id 把结果集转换为关联数组，这样下面可以更高效地操作，否则我们只能两次 foreach 了</span></span><br><span class="line">foreach ($products <span class="keyword">as</span> $key =&gt; $product) &#123;</span><br><span class="line">    $product[<span class="string">'some_other_info'</span>] = array_get($some_other_infos, $product[<span class="string">'id'</span>]);</span><br><span class="line">    $products[$key] = $product;</span><br><span class="line">&#125;</span><br><span class="line">namespace App\Model;</span><br><span class="line"> </span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">AdminUser</span> <span class="keyword">extends</span> <span class="title">BaseModel</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line"> </span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">admin_user_info</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;hasOne(AdminUserInfo::<span class="class"><span class="keyword">class</span>)</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">$adminUsers = AdminUser::limit(<span class="number">10</span>)-&gt;get();</span><br><span class="line">$adminUsers-&gt;load(<span class="string">'admin_user_info'</span>);</span><br><span class="line">array_get、data_get 方法代替多个 isset 判断</span><br><span class="line"><span class="comment">// 获取一个用户下文章的一条评论</span></span><br><span class="line">$user = User::<span class="keyword">with</span>([<span class="string">'article.comment'</span>])-&gt;first();</span><br><span class="line">$content = isset($user-&gt;article) ? (isset($user-&gt;article-&gt;comment) ? $user-&gt;article-&gt;comment : <span class="string">''</span>) : <span class="string">''</span>; <span class="comment">// 传统写法</span></span><br><span class="line">$content = data_get($user, <span class="string">'article.comment.content'</span>); <span class="comment">// 评论内容</span></span><br><span class="line">单数命名时候 Model 类不用定义 protected $table</span><br><span class="line">重写 Model 类的 getTable 方法</span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">getTable</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (isset($<span class="keyword">this</span>-&gt;table)) &#123;</span><br><span class="line">        <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;table;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">return</span> str_replace(<span class="string">'\\'</span>, <span class="string">''</span>, <span class="attr">Str</span>::snake(class_basename($<span class="keyword">this</span>)));</span><br><span class="line">&#125;</span><br><span class="line">$validator = \Validator::make(request()-&gt;all(), [</span><br><span class="line">    <span class="string">'buyer_id'</span> =&gt; <span class="string">'required'</span>,</span><br><span class="line">    <span class="string">'amount'</span> =&gt; <span class="string">'required|numeric|gt:0'</span></span><br><span class="line">], [</span><br><span class="line">    <span class="string">'buyer_id.required'</span> =&gt; <span class="string">':attribute不能为空'</span>,</span><br><span class="line">    <span class="string">'amount.required'</span> =&gt; <span class="string">'请填写:attribute'</span>,</span><br><span class="line">    <span class="string">'amount.numeric'</span> =&gt; <span class="string">':attribute必须为数字'</span>,</span><br><span class="line">    <span class="string">'amount.gt'</span> =&gt; <span class="string">':attribute必须大于0'</span></span><br><span class="line">], [</span><br><span class="line">    <span class="string">'buyer_id'</span> =&gt; <span class="string">'客户id'</span>,</span><br><span class="line">    <span class="string">'amount'</span> =&gt; <span class="string">'金额'</span></span><br><span class="line">]);</span><br><span class="line"><span class="keyword">if</span> ($validator-&gt;fails()) &#123;</span><br><span class="line">    <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;ajaxFail($validator-&gt;messages()-&gt;first());</span><br><span class="line">&#125; https:<span class="comment">//blog.baiguiren.com/2018/07/29/laravel/%E4%B8%AA%E4%BA%BA%E5%9C%A8%20Laravel%20%E5%BC%80%E5%8F%91%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%88%B0%E7%9A%84%E4%B8%80%E4%BA%9B%E6%8A%80%E5%B7%A7(%E6%8C%81%E7%BB%AD%E6%9B%B4%E6%96%B0)/</span></span><br></pre></td></tr></table></figure>
<h3 id="外部调用类的私有方法"><a href="#外部调用类的私有方法" class="headerlink" title="外部调用类的私有方法"></a>外部调用类的私有方法</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">A</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    protected $protected = <span class="string">'protected'</span>;</span><br><span class="line"></span><br><span class="line">    private $private = <span class="string">'private'</span>;</span><br><span class="line"></span><br><span class="line">    protected <span class="function"><span class="keyword">function</span> <span class="title">protectedMethod</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">'Hello protected'</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    private <span class="function"><span class="keyword">function</span> <span class="title">privateMethod</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">'Hello private'</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">__get</span>(<span class="params">$name</span>)</span></span><br><span class="line"><span class="function">            </span>&#123;</span><br><span class="line">                <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;$name;</span><br><span class="line">            &#125;</span><br><span class="line">    </span><br><span class="line">            public <span class="function"><span class="keyword">function</span> <span class="title">__call</span>(<span class="params">$name, $arguments</span>)</span></span><br><span class="line"><span class="function">            </span>&#123;</span><br><span class="line">                <span class="keyword">return</span> $<span class="keyword">this</span>-&gt;$name(...$<span class="built_in">arguments</span>);</span><br><span class="line">            &#125;</span><br><span class="line">&#125;</span><br><span class="line">$test = <span class="keyword">new</span> A();</span><br><span class="line"></span><br><span class="line">$test-&gt;protected;</span><br><span class="line">$test-&gt;private;</span><br><span class="line">$test-&gt;protectedMethod();</span><br><span class="line">$test-&gt;privateMethod();</span><br><span class="line">$test = <span class="function"><span class="keyword">function</span> (<span class="params"></span>) </span>&#123;</span><br><span class="line">    echo $<span class="keyword">this</span>-&gt;private;</span><br><span class="line">    echo $<span class="keyword">this</span>-&gt;privateMethod();</span><br><span class="line">&#125;;</span><br><span class="line">$test = $test-&gt;bindTo(<span class="keyword">new</span> A(), <span class="string">'A'</span>);</span><br><span class="line">$test();</span><br></pre></td></tr></table></figure>
<h3 id="30-分钟未付款自动取消订单"><a href="#30-分钟未付款自动取消订单" class="headerlink" title="30 分钟未付款自动取消订单"></a>30 分钟未付款自动取消订单</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br></pre></td><td class="code"><pre><span class="line">先保证 redis 的版本大于 <span class="number">2.8</span> ，现在绝大部分不成问题了，然后修改 redis 的配置文件，加入：notify-keyspace-events <span class="string">"Ex"</span></span><br><span class="line">Cache::store(<span class="string">'redis'</span>)-&gt;put(<span class="string">'ORDER_CONFIRM:'</span>.$order-&gt;id,$order-&gt;id,<span class="number">30</span>); <span class="comment">// 30分钟后过期--执行取消订单</span></span><br><span class="line"> 然后我们来监听 ORDER_CONFIRM:ORDER_ID 的过期事件</span><br><span class="line">先建个命令，我们一会儿的监听全靠他了。</span><br><span class="line">php artisan make:command OrderExpireListen</span><br><span class="line">  然后把命令执行文件 app\Console\Commands\OrderExpireListen.php 写成这样:</span><br><span class="line">namespace App\Console\Commands;</span><br><span class="line">use App\Http\Models\Order;</span><br><span class="line">use Illuminate\Console\Command;</span><br><span class="line">use Illuminate\Support\Facades\Redis <span class="keyword">as</span> Redis;</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">OrderExpireListen</span> <span class="keyword">extends</span> <span class="title">Command</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * The name and signature of the console command.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * @var string</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    protected $signature = <span class="string">'order:expire'</span>;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * The console command description.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * @var string</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    protected $description = <span class="string">'监听订单创建，在30分钟后如果没付款取消订单。'</span>;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * Create a new command instance.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * @return void</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        parent::__construct();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * Execute the console command.</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * @return mixed</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">handle</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">//</span></span><br><span class="line">        $cachedb = config(<span class="string">'database.redis.cache.database'</span>,<span class="number">0</span>);</span><br><span class="line">        $pattern = <span class="string">'__keyevent@'</span>.$cachedb.<span class="string">'__:expired'</span>;</span><br><span class="line">        Redis::subscribe($pattern,<span class="function"><span class="keyword">function</span> (<span class="params">$channel</span>)</span>&#123;     <span class="comment">// 订阅键过期事件</span></span><br><span class="line">            $key_type = str_before($channel,<span class="string">':'</span>);</span><br><span class="line">            <span class="keyword">switch</span> ($key_type) &#123;</span><br><span class="line">                <span class="keyword">case</span> <span class="string">'ORDER_CONFIRM'</span>:</span><br><span class="line">                    $order_id = str_after($channel,<span class="string">':'</span>);    <span class="comment">// 取出订单 ID</span></span><br><span class="line">                    $order = Order::find($order_id);</span><br><span class="line">                    <span class="keyword">if</span> ($order) &#123;</span><br><span class="line">                        $order-&gt;cancel(); <span class="comment">// 执行取消操作</span></span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="keyword">case</span> <span class="string">'ORDER_OTHEREVENT'</span>:</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">                <span class="keyword">default</span>:</span><br><span class="line">                    <span class="keyword">break</span>;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"> 文件好了之后，使用</span><br><span class="line">php artisan order:expire</span><br><span class="line"> </span><br><span class="line">解决自动断开连接超时现象</span><br><span class="line">你改下 app\config\database.php 中 redis 节，增加一个 read_write_timeout :</span><br><span class="line"> <span class="string">'redis'</span> =&gt; [</span><br><span class="line">        <span class="string">'client'</span> =&gt; <span class="string">'predis'</span>,</span><br><span class="line">        <span class="string">'default'</span> =&gt; [</span><br><span class="line">            <span class="string">'host'</span> =&gt; env(<span class="string">'REDIS_HOST'</span>, <span class="string">'127.0.0.1'</span>),</span><br><span class="line">            <span class="string">'password'</span> =&gt; env(<span class="string">'REDIS_PASSWORD'</span>, <span class="literal">null</span>),</span><br><span class="line">            <span class="string">'port'</span> =&gt; env(<span class="string">'REDIS_PORT'</span>, <span class="number">6379</span>),</span><br><span class="line">            <span class="string">'database'</span> =&gt; env(<span class="string">'REDIS_DB'</span>, <span class="number">0</span>),</span><br><span class="line">            <span class="string">'read_write_timeout'</span> =&gt; env(<span class="string">'REDIS_RW_TIMEOUT'</span>, <span class="number">5</span>),  <span class="comment">// 读写超时设定</span></span><br><span class="line">        ],</span><br><span class="line">    ],</span><br><span class="line">最后：使用supervisor监听order:expire  http:<span class="comment">//118.25.60.91:9000/articles/30-fen-zhong-wei-fu-kuan-zi-dong-qu-xiao-ding-dan</span></span><br><span class="line">https:<span class="comment">//crazyfzw.github.io/2019/03/26/redis-keyspace-notifications/ </span></span><br><span class="line">http:<span class="comment">//redisdoc.com/topic/notification.html</span></span><br></pre></td></tr></table></figure>
<h3 id="guzzle异步请求"><a href="#guzzle异步请求" class="headerlink" title="guzzle异步请求"></a>guzzle异步请求</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">$request = <span class="keyword">new</span> \GuzzleHttp\Psr7\Request(<span class="string">'GET'</span>, <span class="string">'http://www.example.com'</span>);</span><br><span class="line">$promise = $client-&gt;sendAsync($request)-&gt;then(<span class="function"><span class="keyword">function</span> (<span class="params">$response</span>) </span>&#123;</span><br><span class="line">  <span class="comment">// 请求完成后的操作</span></span><br><span class="line">  $response-&gt;getBody();</span><br><span class="line">&#125;);</span><br><span class="line">$promise-&gt;wait();</span><br><span class="line"></span><br><span class="line">$client = <span class="keyword">new</span> Client([<span class="string">'base_uri'</span> =&gt; <span class="string">'http://httpbin.org/ip'</span>]);</span><br><span class="line">        $promise = $client-&gt;requestAsync(<span class="string">'GET'</span>, <span class="string">'http://httpbin.org/ip'</span>);</span><br><span class="line">        $promise-&gt;then(</span><br><span class="line">            <span class="function"><span class="keyword">function</span> (<span class="params">ResponseInterface $res</span>) </span>&#123;</span><br><span class="line">                echo $res-&gt;getStatusCode() . <span class="string">"\n"</span>;</span><br><span class="line">            &#125;,</span><br><span class="line">            <span class="function"><span class="keyword">function</span> (<span class="params">RequestException $e</span>) </span>&#123;</span><br><span class="line">                echo $e-&gt;getMessage() . <span class="string">"\n"</span>;</span><br><span class="line">                echo $e-&gt;getRequest()-&gt;getMethod();</span><br><span class="line">            &#125;</span><br><span class="line">        );</span><br><span class="line">        dd($promise);</span><br><span class="line"> <span class="string">"guzzlehttp/guzzle"</span>: <span class="string">"5.3.1"</span>,  </span><br><span class="line"> $client=<span class="keyword">new</span> GuzzleHttp\Client();</span><br><span class="line">         $reqs = $client-&gt;createRequest(<span class="string">'GET'</span>, <span class="string">'http://httpbin.org/ip'</span>, [<span class="string">'future'</span> =&gt; <span class="literal">true</span>]);</span><br><span class="line">         $client-&gt;send($reqs)-&gt;then(<span class="function"><span class="keyword">function</span> (<span class="params">$response</span>)</span>&#123;</span><br><span class="line">             dump($response-&gt;json());<span class="comment">//["origin" =&gt; "49.7.40.196, 49.7.40.196"] 这个输出在ok之后</span></span><br><span class="line">         &#125;);</span><br><span class="line">        </span><br><span class="line">         dump(<span class="string">'ok'</span>);</span><br></pre></td></tr></table></figure>
<h3 id="删除数组元素"><a href="#删除数组元素" class="headerlink" title="删除数组元素"></a>删除数组元素</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">删除数组元素有两种方式，第一种是使用 unset 方法。</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line">unset($arr[<span class="number">1</span>]);</span><br><span class="line">此方法删除元素后，$arr[<span class="number">1</span>] 为 <span class="literal">null</span> ，所有元素的索引值不变，也就是说元素不会重新排列，所以不是很实用。</span><br><span class="line"></span><br><span class="line">要使元素删除后重新排列顺序，使用 array_splice 方法即可。</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line">array_splice(array,start,length,array);</span><br><span class="line">array_splice 的四个参数中，array 为要删除元素的数组；start 为要开始删除元素的位置（索引值）；length 为要删除的元素数量；最后一个参数为可选参数，允许用一个新元素替代被删除的元素。</span><br><span class="line"></span><br><span class="line">使用 array_splice 删除数组中索引为<span class="number">1</span>的元素：</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line">array_splice($arr,<span class="number">1</span>,<span class="number">1</span>);<span class="comment">//重新索引了 不用array_values</span></span><br></pre></td></tr></table></figure>
<h3 id="如何查Session内容"><a href="#如何查Session内容" class="headerlink" title="如何查Session内容"></a>如何查Session内容</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">首先配置Session存储，使用Memcached</span><br><span class="line"></span><br><span class="line">session.save_handler = memcached </span><br><span class="line">session.save_path = <span class="string">"localhost:11211"</span> </span><br><span class="line">查看session_id</span><br><span class="line"></span><br><span class="line">&lt;?php</span><br><span class="line">session_start();</span><br><span class="line">var_dump(session_id());</span><br><span class="line">我们希望在Memcached里查询Session内容，怎么确定查询的Key呢？</span><br><span class="line"></span><br><span class="line">尝试：</span><br><span class="line"></span><br><span class="line">get vkfc4eefu7ihlu5iv7v3je8rm0 </span><br><span class="line">无效，应该这样:</span><br><span class="line"></span><br><span class="line">get memc.sess.key.vkfc4eefu7ihlu5iv7v3je8rm0</span><br><span class="line">原来在使用Memcached存储Session, key前缀是可以配置的。</span><br><span class="line"></span><br><span class="line">&lt;?php</span><br><span class="line">var_dump(ini_get(<span class="string">'memcached.sess_prefix'</span>));  <span class="comment">// 'memc.sess.key.'</span></span><br><span class="line"></span><br><span class="line">https:<span class="comment">//php1024.com/posts/50.htm</span></span><br></pre></td></tr></table></figure>
<h3 id="redis队列缓存"><a href="#redis队列缓存" class="headerlink" title="redis队列缓存"></a>redis队列缓存</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 加上时间戳存入队列</span></span><br><span class="line">$now_time = date(<span class="string">"Y-m-d H:i:s"</span>);</span><br><span class="line">$redis-&gt;rPush(<span class="string">"call_log"</span>, $_GET[<span class="string">'info'</span>] . <span class="string">"%"</span> . $now_time);</span><br><span class="line">$redis-&gt;close();</span><br><span class="line"></span><br><span class="line"><span class="comment">// init redis</span></span><br><span class="line">$redis_xx = <span class="keyword">new</span> Redis();</span><br><span class="line">$redis_xx-&gt;connect(<span class="string">'ip'</span>, port);</span><br><span class="line">$redis_xx-&gt;auth(<span class="string">"password"</span>);</span><br><span class="line"><span class="comment">// 获取现有消息队列的长度</span></span><br><span class="line">$count = <span class="number">0</span>;</span><br><span class="line">$max = $redis_xx-&gt;lLen(<span class="string">"call_log"</span>);</span><br><span class="line"><span class="comment">// 获取消息队列的内容，拼接sql</span></span><br><span class="line">$insert_sql = <span class="string">"insert into fb_call_log (`interface_name`, `createtime`) values "</span>;</span><br><span class="line"><span class="comment">// 回滚数组</span></span><br><span class="line">$roll_back_arr = array();</span><br><span class="line"><span class="keyword">while</span> ($count &lt; $max) &#123;</span><br><span class="line">    $log_info = $redis_cq01-&gt;lPop(<span class="string">"call_log"</span>);</span><br><span class="line">    $roll_back_arr = $log_info;</span><br><span class="line">    <span class="keyword">if</span> ($log_info == <span class="string">'nil'</span> || !isset($log_info)) &#123;</span><br><span class="line">        $insert_sql .= <span class="string">";"</span>;</span><br><span class="line">        <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 切割出时间和info</span></span><br><span class="line">    $log_info_arr = explode(<span class="string">"%"</span>,$log_info);</span><br><span class="line">    $insert_sql .= <span class="string">" ('"</span>.$log_info_arr[<span class="number">0</span>].<span class="string">"','"</span>.$log_info_arr[<span class="number">1</span>].<span class="string">"'),"</span>;</span><br><span class="line">    $count++;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 判定存在数据，批量入库</span></span><br><span class="line"><span class="keyword">if</span> ($count != <span class="number">0</span>) &#123;</span><br><span class="line">    $link_2004 = mysql_connect(<span class="string">'ip:port'</span>, <span class="string">'user'</span>, <span class="string">'password'</span>);</span><br><span class="line">    <span class="keyword">if</span> (!$link_2004) &#123;</span><br><span class="line">        die(<span class="string">"Could not connect:"</span> . mysql_error());</span><br><span class="line">    &#125;</span><br><span class="line">    $crowd_db = mysql_select_db(<span class="string">'fb_log'</span>, $link_2004);</span><br><span class="line">    $insert_sql = rtrim($insert_sql,<span class="string">","</span>).<span class="string">";"</span>;</span><br><span class="line">    $res = mysql_query($insert_sql);</span><br><span class="line">    <span class="comment">// 输出入库log和入库结果;</span></span><br><span class="line">    echo date(<span class="string">"Y-m-d H:i:s"</span>).<span class="string">"insert "</span>.$count.<span class="string">" log info result:"</span>;</span><br><span class="line">    echo json_encode($res);</span><br><span class="line">    echo <span class="string">"&lt;/br&gt;\n"</span>;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 数据库插入失败回滚</span></span><br><span class="line">    <span class="keyword">if</span>(!$res)&#123;</span><br><span class="line">       foreach($roll_back_arr <span class="keyword">as</span> $k)&#123;</span><br><span class="line">           $redis_xx-&gt;rPush(<span class="string">"call_log"</span>, $k);</span><br><span class="line">       &#125;</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    <span class="comment">// 释放连接</span></span><br><span class="line">    mysql_free_result($res);</span><br><span class="line">    mysql_close($link_2004);</span><br><span class="line">&#125;</span><br><span class="line">http:<span class="comment">//cuihuan.net/2017/01/20/%E3%80%90%E9%AB%98%E5%B9%B6%E5%8F%91%E7%AE%80%E5%8D%95%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E3%80%91redis%E9%98%9F%E5%88%97%E7%BC%93%E5%AD%98%20+%20mysql%20%E6%89%B9%E9%87%8F%E5%85%A5%E5%BA%93%20+%20php%E7%A6%BB%E7%BA%BF%E6%95%B4%E5%90%88/</span></span><br></pre></td></tr></table></figure>
<h3 id="laravel服务容器"><a href="#laravel服务容器" class="headerlink" title="laravel服务容器"></a>laravel服务容器</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">UserStatsCsvExporter</span> <span class="title">implements</span> <span class="title">UserStatsExporterContract</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">export</span>(<span class="params">int $userId</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">         <span class="comment">// Load user statistics...</span></span><br><span class="line">         <span class="comment">// Export file...</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">在控制器中，我们会 <span class="keyword">new</span> 一个类，然后调用里面的 <span class="keyword">export</span> 方法。</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">ExportController</span> <span class="keyword">extends</span> <span class="title">Controller</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">handle</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $userStatsExporter = <span class="keyword">new</span> UserStatsCsvExporter();</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> $userStatsExporter-&gt;<span class="keyword">export</span>(<span class="number">12</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">handle2</span>(<span class="params">UserStatsCsvExporter $userStatsExporter</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> $userStatsExporter-&gt;<span class="keyword">export</span>(<span class="number">12</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">UserStatsCsvExporter</span> <span class="title">implements</span> <span class="title">UserStatsExporterContract</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/** @var Translator */</span></span><br><span class="line">    private $translator;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params">Translator $translator</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;translator = $translator;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">export</span>(<span class="params">int $userId</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// Load user statistics...</span></span><br><span class="line">        <span class="comment">// Export file...</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Translator</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    <span class="comment">/** @var string */</span></span><br><span class="line">    private $language;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params">string $language</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;language = $language;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">translate</span>(<span class="params">string $word</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// Translate word...</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">UserStatsExporterProvider</span> <span class="keyword">extends</span> <span class="title">ServiceProvider</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">register</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;app-&gt;bind(UserStatsCsvExporter::<span class="class"><span class="keyword">class</span>, <span class="title">function</span>() </span>&#123;</span><br><span class="line">           <span class="keyword">return</span> <span class="keyword">new</span> UserStatsCsvExporter(<span class="keyword">new</span> Translator(config(<span class="string">'app.locale'</span>)));</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">绑定到接口</span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">handle</span>(<span class="params">UserStatsXmlExporter $userStatsExporter</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> $userStatsExporter-&gt;<span class="keyword">export</span>(<span class="number">12</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">register</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    $<span class="keyword">this</span>-&gt;app-&gt;bind(UserStatsXmlExporter::<span class="class"><span class="keyword">class</span>, <span class="title">function</span>() </span>&#123;</span><br><span class="line">       <span class="keyword">return</span> <span class="keyword">new</span> UserStatsXmlExporter(<span class="keyword">new</span> Translator(config(<span class="string">'app.locale'</span>))</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">handle</span>(<span class="params">UserStatsExporterContract $userStatsExporter</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> $userStatsExporter-&gt;<span class="keyword">export</span>(<span class="number">12</span>);</span><br><span class="line">&#125;</span><br><span class="line">要让上面代码工作，我们还需要改动服务提供者的代码。</span><br><span class="line"></span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">register</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    $<span class="keyword">this</span>-&gt;app-&gt;bind(UserStatsExporterContract::<span class="class"><span class="keyword">class</span>, <span class="title">function</span>() </span>&#123;</span><br><span class="line">       <span class="keyword">return</span> <span class="keyword">new</span> UserStatsXmlExporter(<span class="keyword">new</span> Translator(config(<span class="string">'app.locale'</span>)));</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">handle</span>(<span class="params">UserStatsExporterContract $userStatsExporter</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    dd(app(UserStatsExporterContract::class), app(UserStatsExporterContract::class));</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> $userStatsExporter-&gt;<span class="keyword">export</span>(<span class="number">12</span>);</span><br><span class="line">&#125;</span><br><span class="line">使用 singleton 来替换 bind 方法即可。</span><br><span class="line"></span><br><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">register</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    $<span class="keyword">this</span>-&gt;app-&gt;singleton(UserStatsExporterContract::<span class="class"><span class="keyword">class</span>, <span class="title">function</span>() </span>&#123;</span><br><span class="line">       <span class="keyword">return</span> <span class="keyword">new</span> UserStatsXmlExporter(<span class="keyword">new</span> Translator(config(<span class="string">'app.locale'</span>)));</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;</span><br><span class="line">https:<span class="comment">//learnku.com/articles/32333</span></span><br></pre></td></tr></table></figure>
<h3 id="反射动态代理"><a href="#反射动态代理" class="headerlink" title="反射动态代理"></a>反射动态代理</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">mysql</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">function</span> <span class="title">connect</span>(<span class="params">$db</span>)</span>&#123;</span><br><span class="line">        echo <span class="string">"连接到数据库$&#123;db[0]&#125;\r\n"</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">sqlproxy</span></span>&#123;</span><br><span class="line">    private $target;</span><br><span class="line">    <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params">$tar</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;target[]=<span class="keyword">new</span> $tar();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="keyword">function</span> <span class="title">__call</span>(<span class="params">$name, $args</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        foreach ($<span class="keyword">this</span>-&gt;target <span class="keyword">as</span> $obj) &#123;</span><br><span class="line">            $r=<span class="keyword">new</span> ReflectionClass($obj);</span><br><span class="line">            <span class="keyword">if</span> ($method= $r-&gt;getMethod($name)) &#123;</span><br><span class="line">                <span class="keyword">if</span> ($method-&gt;isPublic() &amp;&amp; !$method-&gt;isAbstract()) &#123;</span><br><span class="line">                    echo <span class="string">"方法前拦截记录LOG\r\n"</span>;</span><br><span class="line">                    $method-&gt;invoke($obj,$args);</span><br><span class="line">                    echo <span class="string">"方法后拦截\r\n"</span>;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">$obj=<span class="keyword">new</span> sqlproxy(<span class="string">'mysql'</span>);</span><br><span class="line">$obj-&gt;connect(<span class="string">'member'</span>);</span><br><span class="line">方法前拦截记录LOG</span><br><span class="line">连接到数据库member</span><br><span class="line">方法后拦截</span><br><span class="line">https:<span class="comment">//learnku.com/articles/32943</span></span><br></pre></td></tr></table></figure>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">https:<span class="comment">//pecl.php.net/package/imagick  </span></span><br><span class="line">#wget http://pecl.php.net/get/imagick-3.4.4.tgz</span><br><span class="line">#tar -xzvf imagick-3.4.4.tgz</span><br><span class="line">#cd imagick-3.4.4</span><br><span class="line">#phpize</span><br><span class="line">#./configure --with-php-config=/php7/bin/php-config --with-imagick=/usr/local/imagemagick</span><br><span class="line">checking Testing /usr/bin/Wand-config... Doesn<span class="string">'t exist</span></span><br><span class="line"><span class="string">checking Testing /usr/sbin/bin/MagickWand-config... Doesn'</span>t exist</span><br><span class="line">checking Testing /usr/sbin/bin/Wand-config... Doesn<span class="string">'t exist</span></span><br><span class="line"><span class="string">checking Testing /opt/bin/MagickWand-config... Doesn'</span>t exist</span><br><span class="line">checking Testing /opt/bin/Wand-config... Doesn<span class="string">'t exist</span></span><br><span class="line"><span class="string">checking Testing /opt/local/bin/MagickWand-config... Doesn'</span>t exist</span><br><span class="line">checking Testing /opt/local/bin/Wand-config... Doesn<span class="string">'t exist</span></span><br><span class="line"><span class="string">configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"> #yum install ImageMagick-devel -y </span></span><br><span class="line"><span class="string"># ./configure --with-php-config=/php7/bin/php-config --with-imagick=/usr/local/imagemagick</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"> checking whether stripping libraries is possible... yes</span></span><br><span class="line"><span class="string"> checking if libtool supports shared libraries... yes</span></span><br><span class="line"><span class="string"> checking whether to build shared libraries... yes</span></span><br><span class="line"><span class="string"> checking whether to build static libraries... no</span></span><br><span class="line"><span class="string"> </span></span><br><span class="line"><span class="string"> creating libtool</span></span><br><span class="line"><span class="string"> appending configuration tag "CXX" to libtool</span></span><br><span class="line"><span class="string"> configure: creating ./config.status</span></span><br><span class="line"><span class="string"> config.status: creating config.h</span></span><br><span class="line"><span class="string">#make &amp;&amp; make install </span></span><br><span class="line"><span class="string">Build complete.</span></span><br><span class="line"><span class="string">Don'</span>t forget to run <span class="string">'make test'</span>.</span><br><span class="line"></span><br><span class="line">Installing shared extensions:     <span class="regexp">/php7/</span>lib/php/extensions/no-debug-zts<span class="number">-20151012</span>/</span><br><span class="line">Installing header files:          <span class="regexp">/php7/i</span>nclude/php/</span><br><span class="line">php7 --ini</span><br><span class="line">Configuration File (php.ini) Path: <span class="regexp">/opt/</span>php7/etc/</span><br><span class="line">Loaded Configuration File: <span class="regexp">/opt/</span>php7/etc/php.ini</span><br><span class="line">Scan <span class="keyword">for</span> additional .ini files <span class="keyword">in</span>: (none)</span><br><span class="line">Additional .ini files parsed: (none)</span><br><span class="line"> #vi php.ini</span><br><span class="line"> extension=<span class="regexp">/opt/</span>php7/lib/php/extensions/no-debug-zts<span class="number">-20151012</span>/imagick.so</span><br></pre></td></tr></table></figure>
<h3 id="phpstorm-gitbash"><a href="#phpstorm-gitbash" class="headerlink" title="phpstorm gitbash"></a>phpstorm gitbash</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">打开 PHPStorm 的设置，定位到 Tools -&gt; Terminal</span><br><span class="line">将 Shell Path 选项改为 &#123;git 安装目录&#125;\bin\sh.exe，重新打开终端，可以看到已切换成了 git bash</span><br><span class="line">另外 git bash 可能会出现中文乱码的问题，需要在 Git 的安装目录下找到 ./etc/bash.bashrc 文件，在末尾添加：</span><br><span class="line"></span><br><span class="line">$ vim ./etc/bash.bashrc</span><br><span class="line"></span><br><span class="line"># support chinese</span><br><span class="line"><span class="keyword">export</span> LANG=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line"><span class="keyword">export</span> LC_ALL=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line"></span><br><span class="line">https:<span class="comment">//learnku.com/articles/32981</span></span><br></pre></td></tr></table></figure>
<h3 id="composer-找不到文件"><a href="#composer-找不到文件" class="headerlink" title="composer 找不到文件"></a>composer 找不到文件</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"> findClasses 函数中，有这么一个去除代码中 heredoc 或 nowdoc 的操作：</span><br><span class="line"></span><br><span class="line"><span class="comment">// strip heredocs/nowdocs</span></span><br><span class="line">$contents = preg_replace(<span class="string">'&#123;&lt;&lt;&lt;[ \t]*([\'"]?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)(?:\s*)\\2(?=\s+|[;,.)])&#125;s'</span>, <span class="string">'null'</span>, $contents);</span><br><span class="line">问题就出在这个正则。对于内容比较长的类源文件，这个正则替换可能会直接报错返回 <span class="literal">null</span>，这样就导致 composer 无法识别出该类，从而你的应用中就会报类不存在的错误。</span><br><span class="line"></span><br><span class="line">通过调用 preg_last_error () 函数可以获取正则错误代码。我这里返回的错误代码为 <span class="number">2</span>，也就是 PREG_BACKTRACK_LIMIT_ERROR，意思是回溯限制错误。这个错误受 php 配置影响，可以把 pcre.backtrack_limit 参数设置更大或者直接设置成 - <span class="number">1</span> 不受限制（可能会造成性能问题，谨慎操作）。这也是前面提到的为什么有的机器上正常，有的机器上又不正常，原因就在于这个配置不同。</span><br><span class="line"></span><br><span class="line">OK，到此弄清楚是什么原因了。解决办法：<span class="number">1</span>、可以将 pcre.backtrack_limit 参数设置大点再试试 <span class="number">2</span>、看是否能减小类源文件中 heredocs/nowdocs 字符串的大小。此处我的解决办法是直接把这个超长 heredocs 字符串独立到 sql 文件中，代码中读取文件内容即可。</span><br><span class="line"></span><br><span class="line">https:<span class="comment">//learnku.com/articles/32972</span></span><br></pre></td></tr></table></figure>
<h3 id="分组查询"><a href="#分组查询" class="headerlink" title="分组查询"></a>分组查询</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">select <span class="string">`u`</span>.<span class="string">`id`</span>,<span class="string">`u`</span>.<span class="string">`name`</span>,<span class="string">`u`</span>.<span class="string">`num`</span> <span class="keyword">from</span> <span class="string">`users`</span> <span class="keyword">as</span> <span class="string">`u`</span> left join (select <span class="string">`user_id`</span>,count(*) <span class="keyword">as</span> <span class="string">`num`</span> <span class="keyword">from</span> books group by <span class="string">`user_id`</span>) <span class="keyword">as</span> <span class="string">`b`</span> on <span class="string">`u`</span>.id = <span class="string">`b`</span>.user_id  查询每个人的书数量</span><br><span class="line">select distinct <span class="string">`u`</span>.<span class="string">`id`</span>,<span class="string">`u`</span>.<span class="string">`name`</span>,IFNULL( <span class="string">`b`</span>.<span class="string">`num`</span>, <span class="number">0</span> ) AS num <span class="keyword">from</span> <span class="string">`users`</span> <span class="keyword">as</span> <span class="string">`u`</span> left join (select <span class="string">`user_id`</span>,count(*) <span class="keyword">as</span> <span class="string">`num`</span> <span class="keyword">from</span> books group by <span class="string">`user_id`</span>) <span class="keyword">as</span> <span class="string">`b`</span> on <span class="string">`u`</span>.id = <span class="string">`b`</span>.user_id</span><br><span class="line"></span><br><span class="line"> <span class="comment">//统计出所有内部员工的user_id</span></span><br><span class="line"></span><br><span class="line">    $user_ids = [<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>];</span><br><span class="line"></span><br><span class="line">    $bookQuery = Book::selectRaw(<span class="string">'user_id,count(*) as number'</span>)-&gt;whereIn(<span class="string">'user_id'</span>, $user_ids)-&gt;groupBy(<span class="string">'user_id'</span>); <span class="comment">//制作一个query builder</span></span><br><span class="line"></span><br><span class="line">    $users = User::selectRaw(<span class="string">'u.id,IFNULL( b.number, 0 ) AS number'</span>)</span><br><span class="line">        -&gt;<span class="keyword">from</span>(<span class="string">'users as u'</span>)</span><br><span class="line">        -&gt;distinct()</span><br><span class="line">        -&gt;whereIn(<span class="string">'id'</span>, $user_ids)</span><br><span class="line">        -&gt;leftJoin(\DB::raw(<span class="string">"(&#123;$bookQuery-&gt;toSql()&#125;) as b"</span>),<span class="function"><span class="keyword">function</span> (<span class="params">$join</span>) <span class="title">use</span>(<span class="params">$bookQuery</span>)</span>&#123;</span><br><span class="line">            <span class="comment">//toSql()返回的是等待绑定参数的SQL语句</span></span><br><span class="line">            $join-&gt;mergeBindings($bookQuery-&gt;getQuery())-&gt;on(<span class="string">'u.id'</span>,<span class="string">'='</span>,<span class="string">'b.user_id'</span>);</span><br><span class="line">            <span class="comment">//mergeBindings是将SQl的参数进行绑定</span></span><br><span class="line">        &#125;)</span><br><span class="line">        -&gt;get();</span><br><span class="line">https:<span class="comment">//www.guaosi.com/2019/03/19/laravel-with-limit-and-group-show-zero/</span></span><br></pre></td></tr></table></figure>
<h3 id="取k个不重复的数"><a href="#取k个不重复的数" class="headerlink" title="取k个不重复的数"></a>取k个不重复的数</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getRandomN</span>(<span class="params">$max, $num</span>) </span>&#123;</span><br><span class="line">    $count = <span class="number">0</span>;</span><br><span class="line">    $<span class="keyword">return</span> = array();</span><br><span class="line">    <span class="keyword">while</span> ($count &lt; $num) &#123;</span><br><span class="line">        $<span class="keyword">return</span>[] = mt_rand(<span class="number">0</span>, $max);</span><br><span class="line">        $<span class="keyword">return</span> = array_flip(array_flip($<span class="keyword">return</span>));</span><br><span class="line">        $count = count($<span class="keyword">return</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    shuffle($<span class="keyword">return</span>);</span><br><span class="line">    <span class="keyword">return</span> $<span class="keyword">return</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">return</span> getRandomN(<span class="number">20</span>, <span class="number">10</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// output:[7,14,6,12,3,4,15,0,16,10]</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getRandomN</span>(<span class="params">$num, $n</span>)</span>&#123;</span><br><span class="line">    $startArray = range(<span class="number">0</span>, $num);</span><br><span class="line">    $resultArray = [];</span><br><span class="line">    <span class="keyword">for</span>($i = <span class="number">0</span>; $i &lt; $n; $i++)</span><br><span class="line">    &#123;</span><br><span class="line">        $random = mt_rand(<span class="number">0</span>, $num - $i);</span><br><span class="line">        $resultArray[$i] = $startArray[$random];</span><br><span class="line">        $startArray[$random] = $startArray[$num - $i - <span class="number">1</span>];</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> $resultArray;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">return</span> getRandomN(<span class="number">20</span>, <span class="number">10</span>);</span><br><span class="line">https:<span class="comment">//alpha2016.github.io/2019/04/09/PHP%E4%BB%8E0-n%E4%B9%8B%E9%97%B4%E9%9A%8F%E6%9C%BA%E5%8F%96k%E4%B8%AA%E4%B8%8D%E9%87%8D%E5%A4%8D%E7%9A%84%E6%95%B0/</span></span><br></pre></td></tr></table></figure>
<h3 id="Intervention-Image-库处理图片"><a href="#Intervention-Image-库处理图片" class="headerlink" title="Intervention Image 库处理图片"></a>Intervention Image 库处理图片</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br></pre></td><td class="code"><pre><span class="line">composer <span class="built_in">require</span> intervention/image</span><br><span class="line"><span class="comment">// 包含autoload文件</span></span><br><span class="line"><span class="built_in">require</span> <span class="string">'vendor/autoload.php'</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 导入ImageManager类</span></span><br><span class="line">use Intervention\Image\ImageManager;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 创建ImageManager实例并指定要使用的驱动(默认GD库)</span></span><br><span class="line">$manager = <span class="keyword">new</span> ImageManager(array(<span class="string">'driver'</span> =&gt; <span class="string">'imagick'</span>));</span><br><span class="line"></span><br><span class="line"><span class="comment">// 创建Image实例然后操作图片</span></span><br><span class="line">$image = $manager-&gt;make(<span class="string">'public/foo.jpg'</span>)-&gt;resize(<span class="number">300</span>, <span class="number">200</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 创建一个Image对象</span></span><br><span class="line">$img = Image::make(<span class="string">'public/foo.jpg'</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 获取图片文件大小</span></span><br><span class="line">$size = $img-&gt;filesize();</span><br><span class="line"></span><br><span class="line"><span class="comment">// 获取图片尺寸（像素）</span></span><br><span class="line">$width  = $img-&gt;width();</span><br><span class="line">$height = $img-&gt;height();</span><br><span class="line"></span><br><span class="line"><span class="comment">// 调整图片尺寸</span></span><br><span class="line">$img-&gt;resize(<span class="number">300</span>, <span class="number">200</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 调整图片的宽或高</span></span><br><span class="line">$img-&gt;resize(<span class="number">300</span>, <span class="literal">null</span>);</span><br><span class="line">$img-&gt;resize(<span class="literal">null</span>, <span class="number">200</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 调整图片的宽同时保持图片比例</span></span><br><span class="line">$img-&gt;resize(<span class="number">300</span>, <span class="literal">null</span>, <span class="function"><span class="keyword">function</span> (<span class="params">$constraint</span>) </span>&#123;</span><br><span class="line">    $constraint-&gt;aspectRatio();</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 调整图片的高同时保持图片比例</span></span><br><span class="line">$img-&gt;resize(<span class="literal">null</span>, <span class="number">200</span>, <span class="function"><span class="keyword">function</span> (<span class="params">$constraint</span>) </span>&#123;</span><br><span class="line">    $constraint-&gt;aspectRatio();</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 避免处理时造成文件大小增加</span></span><br><span class="line">$img-&gt;resize(<span class="literal">null</span>, <span class="number">400</span>, <span class="function"><span class="keyword">function</span> (<span class="params">$constraint</span>) </span>&#123;</span><br><span class="line">    $constraint-&gt;aspectRatio();</span><br><span class="line">    $constraint-&gt;upsize();</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 转码为其他格式并压缩图片</span></span><br><span class="line">$img-&gt;encode(<span class="string">'jpg'</span>, <span class="number">75</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 转码为 Data URL</span></span><br><span class="line">$img-&gt;encode(<span class="string">'data-url'</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 裁剪图片</span></span><br><span class="line">$img-&gt;crop(<span class="number">100</span>, <span class="number">100</span>, <span class="number">25</span>, <span class="number">25</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 旋转-45度</span></span><br><span class="line">$img-&gt;rotate(<span class="number">-45</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 垂直翻转及水平翻转</span></span><br><span class="line">$img-&gt;flip(<span class="string">'v'</span>);</span><br><span class="line">$img-&gt;flip(<span class="string">'h'</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 以最优方案裁剪为600*360</span></span><br><span class="line">$img-&gt;fit(<span class="number">600</span>, <span class="number">360</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 以最优方案裁剪为200*200</span></span><br><span class="line">$img-&gt;fit(<span class="number">200</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 以默认质量保存图片</span></span><br><span class="line">$img-&gt;save(<span class="string">'public/bar.jpg'</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 以给定质量保存图片</span></span><br><span class="line">$img-&gt;save(<span class="string">'public/bar.png'</span>, <span class="number">60</span>);</span><br><span class="line">https:<span class="comment">//yiming.blog/article/201702121305.html</span></span><br></pre></td></tr></table></figure>
<h3 id="Redis-PubSub实现简单消息推送"><a href="#Redis-PubSub实现简单消息推送" class="headerlink" title="Redis PubSub实现简单消息推送"></a>Redis PubSub实现简单消息推送</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">&lt;head&gt;</span><br><span class="line">      &lt;title&gt;swoole chat room&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">      &lt;meta charset="UTF-8"&gt;</span></span><br><span class="line"><span class="regexp">      &lt;script type="text/</span>javascript<span class="string">"&gt;</span></span><br><span class="line"><span class="string">          if(window.WebSocket)&#123;</span></span><br><span class="line"><span class="string">              // 端口和ip地址对应不要写错</span></span><br><span class="line"><span class="string">              var webSocket = new WebSocket("</span>ws:<span class="comment">//127.0.0.1:9502");</span></span><br><span class="line">              webSocket.onopen = <span class="function"><span class="keyword">function</span> (<span class="params">event</span>) </span>&#123;</span><br><span class="line">                  <span class="comment">//webSocket.send("Hello,WebSocket!"); </span></span><br><span class="line">              &#125;;</span><br><span class="line">              webSocket.onmessage = <span class="function"><span class="keyword">function</span> (<span class="params">event</span>) </span>&#123;</span><br><span class="line">                <span class="keyword">var</span> content = <span class="built_in">document</span>.getElementById(<span class="string">'content'</span>);</span><br><span class="line">                content.innerHTML = content.innerHTML.concat(<span class="string">'&lt;p style="margin-left:20px;height:20px;line-height:20px;"&gt;'</span>+event.data+<span class="string">'&lt;/p&gt;'</span>);</span><br><span class="line">              &#125;</span><br><span class="line">              </span><br><span class="line">              <span class="keyword">var</span> sendMessage = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">                  <span class="keyword">var</span> data = <span class="built_in">document</span>.getElementById(<span class="string">'message'</span>).value;</span><br><span class="line">                  webSocket.send(data);</span><br><span class="line">              &#125;</span><br><span class="line">          &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">              <span class="built_in">console</span>.log(<span class="string">"您的浏览器不支持WebSocket"</span>);</span><br><span class="line">          &#125;</span><br><span class="line">      &lt;<span class="regexp">/script&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>head&gt;</span><br><span class="line">&lt;body&gt;</span><br><span class="line">    &lt;div style=<span class="string">"width:600px;margin:0 auto;border:1px solid #ccc;"</span>&gt;</span><br><span class="line">        &lt;div id=<span class="string">"content"</span> style=<span class="string">"overflow-y:auto;height:300px;"</span>&gt;&lt;/div&gt;</span><br><span class="line">        &lt;hr/&gt;</span><br><span class="line">        &lt;div style=<span class="string">"height:40px"</span>&gt;</span><br><span class="line">            &lt;input type=<span class="string">"text"</span> id=<span class="string">"message"</span> style=<span class="string">"margin-left:10px;height:25px;width:450px;"</span>&gt;</span><br><span class="line">            &lt;button onclick=<span class="string">"sendMessage()"</span> style=<span class="string">"height:28px;width:75px;"</span>&gt;发送&lt;<span class="regexp">/button&gt;</span></span><br><span class="line"><span class="regexp">        &lt;/</span>div&gt;</span><br><span class="line">    &lt;<span class="regexp">/div&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>body&gt;</span><br><span class="line">&lt;<span class="regexp">/html&gt;</span></span><br><span class="line"><span class="regexp"></span></span><br><span class="line"><span class="regexp">&lt;?php</span></span><br><span class="line"><span class="regexp">$server = new swoole_websocket_server("0.0.0.0", 9502);</span></span><br><span class="line"><span class="regexp"></span></span><br><span class="line"><span class="regexp">$server-&gt;on('workerStart', function ($server, $workerId) &#123;</span></span><br><span class="line"><span class="regexp">    $client = new swoole_redis;</span></span><br><span class="line"><span class="regexp">    $client-&gt;on('message', function (swoole_redis $client, $result) use ($server) &#123;</span></span><br><span class="line"><span class="regexp">        if ($result[0] == 'message') &#123;</span></span><br><span class="line"><span class="regexp">            var_dump($result);</span></span><br><span class="line"><span class="regexp">            foreach($server-&gt;connections as $fd) &#123;</span></span><br><span class="line"><span class="regexp">                $server-&gt;push($fd, '频道为： ' $result[1] . ' 发送消息：' . $result[2]);</span></span><br><span class="line"><span class="regexp">            &#125;</span></span><br><span class="line"><span class="regexp">        &#125;</span></span><br><span class="line"><span class="regexp">    &#125;);</span></span><br><span class="line"><span class="regexp">    $client-&gt;connect('127.0.0.1', 6379, function (swoole_redis $client, $result) &#123;</span></span><br><span class="line"><span class="regexp">        $client-&gt;subscribe('message');   /</span><span class="regexp">/ 队列名称可以自定义     &#125;);</span></span><br><span class="line"><span class="regexp">&#125;);</span></span><br><span class="line"><span class="regexp"></span></span><br><span class="line"><span class="regexp">$server-&gt;on('open', function ($server, $request) &#123;</span></span><br><span class="line"><span class="regexp">    $server-&gt;push($request-&gt;fd, "hello;\n");</span></span><br><span class="line"><span class="regexp">&#125;);</span></span><br><span class="line"><span class="regexp"></span></span><br><span class="line"><span class="regexp">/</span><span class="regexp">/ 屏蔽这段会报错 $server-&gt;on('message', function (swoole_websocket_server $server, $request) &#123;</span></span><br><span class="line"><span class="regexp">    $server-&gt;push($request-&gt;fd, "hello");</span></span><br><span class="line"><span class="regexp">&#125;);</span></span><br><span class="line"><span class="regexp"></span></span><br><span class="line"><span class="regexp">$server-&gt;on('close', function ($server, $fd) &#123;</span></span><br><span class="line"><span class="regexp">    echo "client-&#123;$fd&#125; is closed\n";</span></span><br><span class="line"><span class="regexp">    $server-&gt;close($fd);</span></span><br><span class="line"><span class="regexp">&#125;);</span></span><br><span class="line"><span class="regexp"></span></span><br><span class="line"><span class="regexp">$server-&gt;start();</span></span><br><span class="line"><span class="regexp"> https:/</span><span class="regexp">/alpha2016.github.io/</span><span class="number">2019</span>/<span class="number">02</span>/<span class="number">16</span>/PHP,Swoole,Redis-PubSub%E5%AE%<span class="number">9</span>E%E7%<span class="number">8</span>E%B0%E7%AE%<span class="number">80</span>%E5%<span class="number">8</span>D%<span class="number">95</span>%E6%B6%<span class="number">88</span>%E6%<span class="number">81</span>%AF%E6%<span class="number">8</span>E%A8%E9%<span class="number">80</span>%<span class="number">81</span>/</span><br></pre></td></tr></table></figure>
<h3 id="FFmpeg-截取视频"><a href="#FFmpeg-截取视频" class="headerlink" title="FFmpeg 截取视频"></a>FFmpeg 截取视频</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//获取文件路径</span></span><br><span class="line">fwrite(STDOUT, <span class="string">"哪个视频文件:"</span>);</span><br><span class="line">$video_path = trim(fgets(STDIN));</span><br><span class="line"></span><br><span class="line">fwrite(STDOUT, <span class="string">"多少秒截取1张图:"</span>);</span><br><span class="line">$s = trim(fgets(STDIN));</span><br><span class="line"></span><br><span class="line"><span class="comment">//设置输出路径</span></span><br><span class="line">fwrite(STDOUT, <span class="string">"输出到哪里:"</span>);</span><br><span class="line">$export_path = trim(fgets(STDIN));</span><br><span class="line"></span><br><span class="line">$command = system(<span class="string">'ffmpeg -y -i '</span>.$video_path.<span class="string">' -vf "fps=1/'</span>.$s.<span class="string">',scale=iw/4:-1,tile=2x2" -an '</span>.$export_path.<span class="string">'_%d.png'</span>); </span><br><span class="line"></span><br><span class="line"><span class="comment">// fps = 1/2 每2秒截一张图,如果是每秒截一张 参数就是 fps=1</span></span><br><span class="line"><span class="comment">// scale 截图大小,上面的代码是设置宽为原始的1/4大小,高度自动,也可以设置成固定值如:120:80</span></span><br><span class="line"><span class="comment">// tile 网格化,自动将100张图合并成一张大图 https://learnku.com/laravel/t/33066</span></span><br></pre></td></tr></table></figure>
<h3 id="求两个集合的交集"><a href="#求两个集合的交集" class="headerlink" title="求两个集合的交集"></a>求两个集合的交集</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">$m = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>];</span><br><span class="line">$n = [<span class="number">1</span>, <span class="number">4</span>, <span class="number">7</span>, <span class="number">9</span>];</span><br><span class="line">$intersection = [];</span><br><span class="line"></span><br><span class="line">foreach ($m <span class="keyword">as</span> $m_v) &#123;</span><br><span class="line">    foreach ($n <span class="keyword">as</span> $n_v) &#123;</span><br><span class="line">        <span class="keyword">if</span> ($m_v === $n_v) &#123;</span><br><span class="line">            $intersection = $m_v;<span class="comment">//4</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">$m = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>];</span><br><span class="line">$n = [<span class="number">1</span>, <span class="number">4</span>, <span class="number">7</span>, <span class="number">9</span>];</span><br><span class="line">$intersection = [];</span><br><span class="line"></span><br><span class="line"><span class="comment">// 获取两个数组的长度</span></span><br><span class="line">$length_m = count($m);</span><br><span class="line">$length_n = count($n);</span><br><span class="line"></span><br><span class="line"><span class="comment">// 定义两个指针</span></span><br><span class="line">$i = $j = <span class="number">0</span>;</span><br><span class="line">$intersection = [];</span><br><span class="line"></span><br><span class="line"><span class="keyword">while</span> ($i &lt; $length_m &amp;&amp; $j &lt; $length_n) &#123;</span><br><span class="line">    <span class="keyword">if</span> ($m[$i] === $n[$j]) &#123;</span><br><span class="line">        $intersection[] = $m[$i];</span><br><span class="line">    &#125; <span class="keyword">else</span> <span class="keyword">if</span> ($m[$i] &lt; $n[$j]) &#123;</span><br><span class="line">        $i++;</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        $j++;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">https:<span class="comment">//www.hanjiaxin.com/2018/12/13/algorithm-1/</span></span><br></pre></td></tr></table></figure>
<h3 id="无限级分类"><a href="#无限级分类" class="headerlink" title="无限级分类"></a>无限级分类</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br></pre></td><td class="code"><pre><span class="line">&amp; 引用赋值</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">doloop1</span>(<span class="params">&amp;$i = <span class="number">1</span></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    print_r($i);</span><br><span class="line">    $i++;</span><br><span class="line">    <span class="keyword">if</span> ($i &lt;= <span class="number">10</span>) &#123;</span><br><span class="line">        doloop1($i);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">doloop1();</span><br><span class="line"><span class="keyword">static</span> 静态变量</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">doloop2</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">static</span> $i = <span class="number">1</span>;</span><br><span class="line">    print_r($i);</span><br><span class="line">    $i++;</span><br><span class="line">    <span class="keyword">if</span> ($i &lt;= <span class="number">10</span>) &#123;</span><br><span class="line">        doloop2();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">doloop2();</span><br><span class="line">global 全局变量</span><br><span class="line">$i = <span class="number">1</span>;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">doloop3</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    global $i;</span><br><span class="line">    echo $i;</span><br><span class="line">    $i++;</span><br><span class="line">    <span class="keyword">if</span> ($i &lt;= <span class="number">10</span>) &#123;</span><br><span class="line">        doloop3();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">doloop3();</span><br><span class="line">    $data = [</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">1</span>, <span class="string">'title'</span> =&gt; <span class="string">'Electronics'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">0</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">2</span>, <span class="string">'title'</span> =&gt; <span class="string">'Laptops &amp; PC'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">1</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">3</span>, <span class="string">'title'</span> =&gt; <span class="string">'Laptops'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">2</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">4</span>, <span class="string">'title'</span> =&gt; <span class="string">'PC'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">2</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">5</span>, <span class="string">'title'</span> =&gt; <span class="string">'Cameras &amp; photo'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">1</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">6</span>, <span class="string">'title'</span> =&gt; <span class="string">'Camera'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">5</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">7</span>, <span class="string">'title'</span> =&gt; <span class="string">'Phones &amp; Accessories'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">1</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">8</span>, <span class="string">'title'</span> =&gt; <span class="string">'Smartphones'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">7</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">9</span>, <span class="string">'title'</span> =&gt; <span class="string">'Android'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">8</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">10</span>, <span class="string">'title'</span> =&gt; <span class="string">'iOS'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">8</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">11</span>, <span class="string">'title'</span> =&gt; <span class="string">'Other Smartphones'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">8</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">12</span>, <span class="string">'title'</span> =&gt; <span class="string">'Batteries'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">7</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">13</span>, <span class="string">'title'</span> =&gt; <span class="string">'Headsets'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">7</span>],</span><br><span class="line">            [<span class="string">'id'</span> =&gt; <span class="number">14</span>, <span class="string">'title'</span> =&gt; <span class="string">'Screen Protectors'</span>, <span class="string">'parent_id'</span> =&gt; <span class="number">7</span>],</span><br><span class="line">        ];</span><br><span class="line">    </span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 值引用获取无限极分类树</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * @param array $data</span></span><br><span class="line"><span class="comment"> * @return array</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">make_tree</span>(<span class="params">$data</span>)</span></span><br><span class="line"><span class="function"></span>&#123;  </span><br><span class="line">    $refer = array();  </span><br><span class="line">    $tree = array();  </span><br><span class="line">    foreach($data <span class="keyword">as</span> $k =&gt; $v)&#123;  </span><br><span class="line">        $refer[$v[<span class="string">'id'</span>]] = &amp; $data[$k];  <span class="comment">//创建主键的数组引用  </span></span><br><span class="line">    &#125;  </span><br><span class="line"></span><br><span class="line">    foreach($data <span class="keyword">as</span> $k =&gt; $v)&#123;  </span><br><span class="line">        $parent_id = $v[<span class="string">'parent_id'</span>];   <span class="comment">//获取当前分类的父级id  </span></span><br><span class="line">        <span class="keyword">if</span>($parent_id == <span class="number">0</span>)&#123;  </span><br><span class="line">            $tree[] = &amp; $data[$k];   <span class="comment">//顶级栏目</span></span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;  </span><br><span class="line">            <span class="keyword">if</span>(isset($refer[$parent_id]))&#123;  </span><br><span class="line">                $refer[$parent_id][<span class="string">'children'</span>][] = &amp; $data[$k];  <span class="comment">//如果存在父级栏目，则添加进父级栏目的子栏目数组中  </span></span><br><span class="line">            &#125;  </span><br><span class="line">        &#125;  </span><br><span class="line">    &#125;  </span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> $tree;  </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 递归获取无限极分类树</span></span><br><span class="line"><span class="comment"> * </span></span><br><span class="line"><span class="comment"> * @param array $data</span></span><br><span class="line"><span class="comment"> * @param int $parent_id</span></span><br><span class="line"><span class="comment"> * @param int $level</span></span><br><span class="line"><span class="comment"> * @return array</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">make_tree2</span>(<span class="params">$data = [], $parent_id = <span class="number">0</span>, $level = <span class="number">0</span></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    $tree = [];</span><br><span class="line">    <span class="keyword">if</span> ($data &amp;&amp; is_array($data)) &#123;</span><br><span class="line">        foreach ($data <span class="keyword">as</span> $v) &#123;</span><br><span class="line">            <span class="keyword">if</span> ($v[<span class="string">'parent_id'</span>] == $parent_id) &#123;</span><br><span class="line">                $tree[] = [</span><br><span class="line">                    <span class="string">'id'</span> =&gt; $v[<span class="string">'id'</span>],</span><br><span class="line">                    <span class="string">'level'</span> =&gt; $level,</span><br><span class="line">                    <span class="string">'title'</span> =&gt; $v[<span class="string">'title'</span>],</span><br><span class="line">                    <span class="string">'parent_id'</span> =&gt; $v[<span class="string">'parent_id'</span>],</span><br><span class="line">                    <span class="string">'children'</span> =&gt; make_tree2($data, $v[<span class="string">'id'</span>], $level + <span class="number">1</span>),</span><br><span class="line">                ];</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> $tree;</span><br><span class="line">&#125;</span><br><span class="line">获取子节点以及节点的层级</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 引用赋值方式</span></span><br><span class="line"><span class="comment"> * @param array $data</span></span><br><span class="line"><span class="comment"> * @param int $id</span></span><br><span class="line"><span class="comment"> * @param int $level</span></span><br><span class="line"><span class="comment"> * @return array</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getSubTree</span>(<span class="params">$data = [], $id = <span class="number">0</span>, $level = <span class="number">0</span></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">static</span> $tree = [];</span><br><span class="line"></span><br><span class="line">    foreach ($data <span class="keyword">as</span> $key =&gt; $value) &#123;</span><br><span class="line">        <span class="keyword">if</span> ($value[<span class="string">'parent_id'</span>] == $id) &#123;</span><br><span class="line">            $value[<span class="string">'laravel'</span>] = $level;</span><br><span class="line">            $tree[] = $value;</span><br><span class="line">            getSubTree($data, $value[<span class="string">'id'</span>], $level + <span class="number">1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> $tree;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 静态变量方式</span></span><br><span class="line"><span class="comment"> * @param array $data</span></span><br><span class="line"><span class="comment"> * @param int $id</span></span><br><span class="line"><span class="comment"> * @param int $level</span></span><br><span class="line"><span class="comment"> * @return array</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getSubTree</span>(<span class="params">$data = [], $id = <span class="number">0</span>, $level = <span class="number">0</span></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">static</span> $tree = [];</span><br><span class="line"></span><br><span class="line">    foreach ($data <span class="keyword">as</span> $key =&gt; $value) &#123;</span><br><span class="line">        <span class="keyword">if</span> ($value[<span class="string">'parent_id'</span>] == $id) &#123;</span><br><span class="line">            $value[<span class="string">'laravel'</span>] = $level;</span><br><span class="line">            $tree[] = $value;</span><br><span class="line">            getSubTree($data, $value[<span class="string">'id'</span>], $level + <span class="number">1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> $tree;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 全局变量方式</span></span><br><span class="line"><span class="comment"> * @param array $data</span></span><br><span class="line"><span class="comment"> * @param int $id</span></span><br><span class="line"><span class="comment"> * @param int $level</span></span><br><span class="line"><span class="comment"> * @return array</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line">$tree = [];  <span class="comment">//先申明变量</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getSubTree</span>(<span class="params">$data = [], $id = <span class="number">0</span>, $level = <span class="number">0</span></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    global $tree;</span><br><span class="line"></span><br><span class="line">    foreach ($data <span class="keyword">as</span> $key =&gt; $value) &#123;</span><br><span class="line">        <span class="keyword">if</span> ($value[<span class="string">'parent_id'</span>] == $id) &#123;</span><br><span class="line">            $value[<span class="string">'laravel'</span>] = $level;</span><br><span class="line">            $tree[] = $value;</span><br><span class="line">            getSubTree($data, $value[<span class="string">'id'</span>], $level + <span class="number">1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> $tree;</span><br><span class="line">&#125;</span><br><span class="line">通过 pid 获取所有上级分类 常用于面包屑导航</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * getParentsByParentId2($categories, 9)</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * @param array $data</span></span><br><span class="line"><span class="comment"> * @param $parent_id</span></span><br><span class="line"><span class="comment"> * @return array</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getParentsByParentId</span>(<span class="params">$data = [], $parent_id</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">static</span> $categories = [];</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> ($data &amp;&amp; is_array($data)) &#123;</span><br><span class="line">        foreach ($data <span class="keyword">as</span> $item) &#123;</span><br><span class="line">            <span class="keyword">if</span> ($item[<span class="string">'id'</span>] == $parent_id) &#123;</span><br><span class="line">                $categories[] = $item;</span><br><span class="line">                getParentsByParentId($data, $item[<span class="string">'parent_id'</span>]);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> $categories;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">getParentsByParentId2</span>(<span class="params">$data = [], $parent_id</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    $categories = [];</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> ($data &amp;&amp; is_array($data)) &#123;</span><br><span class="line">        foreach ($data <span class="keyword">as</span> $item) &#123;</span><br><span class="line">            <span class="keyword">if</span> ($item[<span class="string">'id'</span>] == $parent_id) &#123;</span><br><span class="line">                $categories[] = $item;</span><br><span class="line">                $categories = array_merge($categories, getParentsByParentId2($data, $item[<span class="string">'parent_id'</span>]));</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> $categories;</span><br><span class="line">&#125;</span><br><span class="line">https:<span class="comment">//learnku.com/articles/28252</span></span><br></pre></td></tr></table></figure>
<h3 id="MVC-的-“拓展-“模式"><a href="#MVC-的-“拓展-“模式" class="headerlink" title="MVC 的 “拓展 “模式"></a>MVC 的 “拓展 “模式</h3><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">我们把 model 当成 Eloquent <span class="class"><span class="keyword">class</span>，用一个处理数据库逻辑的 <span class="title">Repository</span> 来辅助它，同样对于 <span class="title">controller</span> 来言，它也有一个辅助它的功臣，那就是能处理商业逻辑 <span class="title">Service</span>，这样就解决了臃肿的问题，<span class="title">view</span> 呢？我们是不是忽略了它，并不是的，它也有属于它的处理显示逻辑的 <span class="title">Presenter</span>。</span></span><br><span class="line"><span class="class">由于 <span class="title">SOLID</span> 的单一职责原则与依赖反转原则：我们将数据库逻辑从 <span class="title">model</span> 分离出来，由 <span class="title">repository</span> 辅助 <span class="title">model</span>，将 <span class="title">model</span> 依赖注入进 <span class="title">repository</span>。同样我们将商业逻辑从 <span class="title">controller</span> 分离出来，由 <span class="title">service</span> 辅助 <span class="title">controller</span>，将 <span class="title">service</span> 依赖注入进 <span class="title">controller</span>。显示逻辑也从 <span class="title">view</span> 分离出来，由 <span class="title">presenter</span> 辅助 <span class="title">view</span>，将 <span class="title">presenter</span> 依赖注入进 <span class="title">view</span>。这样写就避免了臃肿和后期维护的不方便。</span></span><br><span class="line">https://learnku.com/articles/33413</span><br></pre></td></tr></table></figure>
<h3 id="window-composer-reuqire"><a href="#window-composer-reuqire" class="headerlink" title="window composer reuqire"></a>window composer reuqire</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">composer <span class="built_in">require</span> <span class="string">"overtrue/laravel-wechat:~4.0"</span> </span><br><span class="line">实测 Linux 安装 PHP 扩展 pcntl 也可解决。</span><br><span class="line"></span><br><span class="line">如使用 Windows，可composer.json 中增加以下两个字段 config（安装 ext-posix 和 ext-pcntl 的 php7<span class="number">.2</span> 版本扩展）</span><br><span class="line"><span class="string">"platform"</span>: &#123; <span class="string">"ext-pcntl"</span>: <span class="string">"7.2"</span>, <span class="string">"ext-posix"</span>: <span class="string">"7.2"</span>&#125;</span><br><span class="line">https:<span class="comment">//learnku.com/laravel/t/33416</span></span><br></pre></td></tr></table></figure>
<h3 id="位非运算"><a href="#位非运算" class="headerlink" title="位非运算"></a>位非运算</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">echo ~<span class="number">48</span>&amp;~<span class="number">75</span>;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 最好了解下二进制的四则运算和位运算以及运算电路的相关涉及知识^_^</span></span><br><span class="line"><span class="comment"> * 48的二进制值是：00110000 十六进制值是：ffffff30【我系统是64位的输出的结果就是这样】</span></span><br><span class="line"><span class="comment"> * 其实呢计算机内存在存储数据的时候会把负数转换为补码存储【正数的原码，反码，补码完全一样】</span></span><br><span class="line"><span class="comment"> * 而负数呢最高位为1用于表示负数，它的反码呢和正数是相反的，需要将0转换为1，1转换为0，补码操作就是加1操作</span></span><br><span class="line"><span class="comment"> * 当然不同位数的内存长度不一样</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * 75的二进制值是：01001011[我按8位算] 【如果是16位的就是：11111111 01001011，32位，64位的也是同样的道理】</span></span><br><span class="line"><span class="comment"> * echo ~48;//结果为-49</span></span><br><span class="line"><span class="comment"> *          //1、转换为二进制时结果为：00110000【64位系统十六进制就是ffffff30】</span></span><br><span class="line"><span class="comment"> *          //2、此时反码为：11001111【64位系统十六进制就是ffffffcf】</span></span><br><span class="line"><span class="comment"> *          //3、减1操作为：11001110 【64位系统十六进制就是ffffffce】【11111111 11111111 11111111 11001110】</span></span><br><span class="line"><span class="comment"> *          //4、还原为：00110001【64位系统十六进制就是80000031】【二进制为：10000000  00000000 00000000 00110001】</span></span><br><span class="line"><span class="comment"> *          //5、二进制求和结果为：1+16+32=49【注意二进制的最高位1表示负数】输出的结果是：-49</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * echo ~75;//结果为-76，一样的套路</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * echo ~48&amp;~75;//结果却是124</span></span><br><span class="line"><span class="comment"> * 1、48的反码结果为：1100 1111</span></span><br><span class="line"><span class="comment"> * 2、75的的码结果为：1011 0100</span></span><br><span class="line"><span class="comment"> * 3、它们俩相与结果为：1000 0100  【十六进制为：ffffff84】【减1操作后为ffffff83】【自己想想十六进制如何数数^_^】</span></span><br><span class="line"><span class="comment"> * 4、还原后为：0111 1100【十六进制为：8000007c】【二进制结果为：10000000  00000000 00000000 01111100】</span></span><br><span class="line"><span class="comment"> * 5、求和结果为：-124</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line">它的结果是：<span class="number">-124</span> </span><br><span class="line">https:<span class="comment">//learnku.com/articles/33382</span></span><br></pre></td></tr></table></figure>
<h3 id="php-html-to-pdf-image"><a href="#php-html-to-pdf-image" class="headerlink" title="php html to pdf image"></a>php html to pdf image</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">git clone https:<span class="comment">//github.com/krakjoe/wkhtmltox</span></span><br><span class="line">cd wkhtmltox</span><br><span class="line">phpize</span><br><span class="line"><span class="comment">// 这里因为每个人安装环境不一样 /path/to/wkhtmltox/installation 请将这个地址替为wkhtmltox真实的安装路径</span></span><br><span class="line"> <span class="comment">/// PATH 替换为真实的php配置路径</span></span><br><span class="line">./configure --<span class="keyword">with</span>-wkhtmltox=<span class="regexp">/path/</span>to/wkhtmltox/installation --<span class="keyword">with</span>-php-config = PATH</span><br><span class="line">make</span><br><span class="line">make install</span><br><span class="line">将生成的 wkhtmltox.so 添加到 php.ini 的配置中，重启 php</span><br><span class="line">use wkhtmltox\PDF\Converter <span class="keyword">as</span> PDFConverter;</span><br><span class="line">use wkhtmltox\PDF\<span class="built_in">Object</span> <span class="keyword">as</span> PDFObject;</span><br><span class="line"></span><br><span class="line">$converter = <span class="keyword">new</span> PDFConverter([</span><br><span class="line">    <span class="string">"out"</span> =&gt; <span class="string">"test.pdf"</span></span><br><span class="line">]);</span><br><span class="line"></span><br><span class="line">$converter-&gt;add(<span class="keyword">new</span> PDFObject(</span><br><span class="line">    file_get_contents(<span class="string">"http://www.baidu.com"</span>)));</span><br><span class="line"></span><br><span class="line">$converter-&gt;convert();</span><br><span class="line"></span><br><span class="line">use wkhtmltox\Image\Converter <span class="keyword">as</span> ImageConverter;</span><br><span class="line"><span class="comment">// 这里第一个参数可以传入 ` html ` 的字符串</span></span><br><span class="line">$converter = <span class="keyword">new</span> ImageConverter(<span class="literal">null</span>, [</span><br><span class="line">    <span class="string">"fmt"</span> =&gt; <span class="string">"png"</span>,</span><br><span class="line">    <span class="string">"in"</span> =&gt; <span class="string">"http://www.baidu.com"</span>,</span><br><span class="line">    <span class="string">"out"</span> =&gt; <span class="string">"test.png"</span></span><br><span class="line">]);</span><br><span class="line"></span><br><span class="line">$converter = <span class="keyword">new</span> ImageConverter($str, [</span><br><span class="line">    <span class="string">"fmt"</span> =&gt; <span class="string">"jpg"</span>,</span><br><span class="line">    <span class="string">"out"</span> =&gt; <span class="string">"test.jpg"</span></span><br><span class="line">]);</span><br><span class="line">$converter-&gt;convert();</span><br><span class="line">https:<span class="comment">//learnku.com/articles/13472/teach-you-how-to-use-php-to-generate-pdf-and-image-gracefully</span></span><br></pre></td></tr></table></figure>
<h3 id="控制反转，依赖注入"><a href="#控制反转，依赖注入" class="headerlink" title="控制反转，依赖注入"></a>控制反转，依赖注入</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 定义写日志的接口规范</span></span><br><span class="line">interface Log</span><br><span class="line">&#123;</span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">write</span>(<span class="params"></span>);   </span></span><br><span class="line"><span class="function">&#125;</span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function">// 文件记录日志</span></span><br><span class="line"><span class="function"><span class="title">class</span> <span class="title">FileLog</span> <span class="title">implements</span> <span class="title">Log</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">write</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        echo <span class="string">'file log write...'</span>;</span><br><span class="line">    &#125;   </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 数据库记录日志</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">DatabaseLog</span> <span class="title">implements</span> <span class="title">Log</span></span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">write</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        echo <span class="string">'database log write...'</span>;</span><br><span class="line">    &#125;   </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 程序操作类</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">User</span> </span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    protected $fileLog;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;fileLog = <span class="keyword">new</span> FileLog();   </span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">login</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// 登录成功，记录登录日志</span></span><br><span class="line">        echo <span class="string">'login success...'</span>;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;fileLog-&gt;write();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">$user = <span class="keyword">new</span> User();</span><br><span class="line">$user-&gt;login();</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">User</span> </span></span><br><span class="line"><span class="class"></span>&#123;</span><br><span class="line">    protected $log;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params">Log $log</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;log = $log;   </span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">login</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// 登录成功，记录登录日志</span></span><br><span class="line">        echo <span class="string">'login success...'</span>;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;log-&gt;write();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">$user = <span class="keyword">new</span> User(<span class="keyword">new</span> DatabaseLog());</span><br><span class="line">$user-&gt;login();</span><br><span class="line"></span><br><span class="line"><span class="comment">// routes/web.php</span></span><br><span class="line">Route::get(<span class="string">'/post/store'</span>, <span class="string">'PostController@store'</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">// App\Http\Controllers</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">PostController</span> <span class="keyword">extends</span> <span class="title">Controller</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">store</span>(<span class="params">Illuminate\Http\Request $request</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;validate($request, [</span><br><span class="line">            <span class="string">'category_id'</span> =&gt; <span class="string">'required'</span>,</span><br><span class="line">            <span class="string">'title'</span> =&gt; <span class="string">'required|max:255|min:4'</span>,</span><br><span class="line">            <span class="string">'body'</span> =&gt; <span class="string">'required|min:6'</span>,</span><br><span class="line">        ]);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 获取User的reflectionClass对象</span></span><br><span class="line">$reflector = <span class="keyword">new</span> reflectionClass(User::<span class="class"><span class="keyword">class</span>)</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 拿到User的构造函数</span></span><br><span class="line">$<span class="keyword">constructor</span> = $reflector-&gt;getConstructor();</span><br><span class="line"></span><br><span class="line">// 拿到User的构造函数的所有依赖参数</span><br><span class="line">$dependencies = $<span class="keyword">constructor</span>-&gt;getParameters();</span><br><span class="line"></span><br><span class="line">// 创建user对象</span><br><span class="line">$user = $reflector-&gt;newInstance();</span><br><span class="line"></span><br><span class="line">// 创建user对象，需要传递参数的</span><br><span class="line">$user = $reflector-&gt;newInstanceArgs($dependencies = []);</span><br><span class="line">这时候我们可以创建一个 make 方法，传入 User，利用反射机制拿到 User 的构造函数，进而得到构造函数的参数对象。用递归的方式创建参数依赖。最后调用 newInstanceArgs 方法生成 User 实例。 可能有些同学还不是很理解。下面我们用代码去简单模拟下</span><br><span class="line"></span><br><span class="line">function make($concrete)&#123;</span><br><span class="line">    <span class="comment">// 或者User的反射类</span></span><br><span class="line">    $reflector = <span class="keyword">new</span> ReflectionClass($concrete);</span><br><span class="line">    <span class="comment">// User构造函数</span></span><br><span class="line">    $<span class="keyword">constructor</span> = $reflector-&gt;getConstructor();</span><br><span class="line">    // User构造函数参数</span><br><span class="line">    $dependencies = $<span class="keyword">constructor</span>-&gt;getParameters();</span><br><span class="line">    // 最后生成User    </span><br><span class="line">    return $reflector-&gt;newInstanceArgs($dependencies);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">$user = make('User');</span><br><span class="line">$user-&gt;login();</span><br><span class="line"></span><br><span class="line">// 注意我们这里需要修改一下User的构造函数，如果不去修改。反射是不能动态创建接口的，那如果非要用接口该怎么处理呢？下一节我们讲Ioc容器的时候会去解决。</span><br><span class="line"></span><br><span class="line">class User </span><br><span class="line">&#123;</span><br><span class="line">    protected $log;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">__construct</span>(<span class="params">FileLog $log</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;log = $log;   </span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public <span class="function"><span class="keyword">function</span> <span class="title">login</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// 登录成功，记录登录日志</span></span><br><span class="line">        echo <span class="string">'login success...'</span>;</span><br><span class="line">        $<span class="keyword">this</span>-&gt;log-&gt;write();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">make</span>(<span class="params">$concrete</span>)</span>&#123;</span><br><span class="line"></span><br><span class="line">    $reflector = <span class="keyword">new</span> ReflectionClass($concrete);</span><br><span class="line">    $<span class="keyword">constructor</span> = $reflector-&gt;getConstructor();</span><br><span class="line">    // 为什么这样写的? 主要是递归。比如创建FileLog不需要传入参数。</span><br><span class="line">    if(is_null($<span class="keyword">constructor</span>)) &#123;</span><br><span class="line">        <span class="keyword">return</span> $reflector-&gt;newInstance();</span><br><span class="line">    &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">        <span class="comment">// 构造函数依赖的参数</span></span><br><span class="line">        $dependencies = $<span class="keyword">constructor</span>-&gt;getParameters();</span><br><span class="line">        // 根据参数返回实例，如FileLog</span><br><span class="line">        $instances = getDependencies($dependencies);</span><br><span class="line">        return $reflector-&gt;newInstanceArgs($instances);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">function getDependencies($paramters) &#123;</span><br><span class="line">    $dependencies = [];</span><br><span class="line">    foreach ($paramters <span class="keyword">as</span> $paramter) &#123;</span><br><span class="line">        $dependencies[] = make($paramter-&gt;getClass()-&gt;name);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> $dependencies;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">$user = make(<span class="string">'User'</span>);</span><br><span class="line">$user-&gt;login();</span><br><span class="line">https:<span class="comment">//www.tinker777.com/show/12</span></span><br></pre></td></tr></table></figure>
<h3 id="英文字符占-0-5-个，中文字符占-1-个"><a href="#英文字符占-0-5-个，中文字符占-1-个" class="headerlink" title="英文字符占 0.5 个，中文字符占 1 个"></a>英文字符占 0.5 个，中文字符占 1 个</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 计算单字节.</span></span><br><span class="line">    preg_match_all(<span class="string">'/[a-zA-Z0-9_]/'</span>, $value, $single);</span><br><span class="line">    $single = count($single[<span class="number">0</span>]) / <span class="number">2</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 多子节长度.</span></span><br><span class="line">    $double = mb_strlen(preg_replace(<span class="string">'([a-zA-Z0-9_])'</span>, <span class="string">''</span>, $value));</span><br><span class="line"></span><br><span class="line">    $length = $single + $double;</span><br><span class="line">    <span class="function"><span class="keyword">function</span> <span class="title">str_display_len</span> (<span class="params">string $str</span>)</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        preg_match_all(<span class="string">'/[a-zA-Z0-9_]/'</span>, $str, $single);</span><br><span class="line">    </span><br><span class="line">        <span class="keyword">return</span> count($single[<span class="number">0</span>]) / <span class="number">2</span> + mb_strlen(preg_replace(<span class="string">'([a-zA-Z0-9_])'</span>, <span class="string">''</span>, $str));</span><br><span class="line">    &#125;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">the_fucking_length_function</span>(<span class="params">$str</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> strlen(mb_convert_encoding($str, <span class="string">'GB2312'</span>)) / <span class="number">2</span>;</span><br><span class="line">    <span class="comment">//$length = (strlen($value) + mb_strlen($value)) / 2;</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">mbstrlen</span>(<span class="params">$str</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> ceil((strlen($str) + mb_strlen($str, <span class="string">"UTF8"</span>)) / <span class="number">2</span>);</span><br><span class="line">&#125;</span><br><span class="line"> mb_strwidth (<span class="string">'中国123'</span>,<span class="string">'utf-8'</span>)<span class="comment">//7</span></span><br><span class="line">https:<span class="comment">//learnku.com/articles/4956/following-my-unique-needs-of-the-english-characters-accounted-for-05-chinese-characters-accounted-for-1</span></span><br><span class="line">https:<span class="comment">//www.php.net/manual/zh/function.mb-strwidth.php</span></span><br></pre></td></tr></table></figure>
<h3 id="支付宝-App-第三方登录获取-用户信息"><a href="#支付宝-App-第三方登录获取-用户信息" class="headerlink" title="支付宝 App 第三方登录获取 用户信息"></a>支付宝 App 第三方登录获取 用户信息</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment">  * AlipayToken 获得用户 请求token, 通过它获得 用户信息</span></span><br><span class="line"><span class="comment">  * </span></span><br><span class="line"><span class="comment">  * 需要按照支付宝加签流程来。</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"> public <span class="function"><span class="keyword">function</span> <span class="title">userInfo</span>(<span class="params">$app_auth_token</span>)</span></span><br><span class="line"><span class="function"> </span>&#123;</span><br><span class="line">     $infoArr = [</span><br><span class="line">         <span class="string">'method'</span> =&gt; <span class="string">'alipay.system.oauth.token'</span>,</span><br><span class="line">         <span class="string">'app_id'</span> =&gt; $<span class="keyword">this</span>-&gt;app_id,</span><br><span class="line">         <span class="string">'charset'</span> =&gt; <span class="string">'utf-8'</span>,</span><br><span class="line">         <span class="string">'sign_type'</span> =&gt; <span class="string">'RSA2'</span>,</span><br><span class="line">         <span class="string">'timestamp'</span> =&gt; date(<span class="string">'Y-m-d H:i:s'</span>),</span><br><span class="line">         <span class="string">'version'</span> =&gt; <span class="string">'1.0'</span>,</span><br><span class="line">         <span class="string">'code'</span> =&gt; $app_auth_token,</span><br><span class="line">         <span class="string">'grant_type'</span> =&gt; <span class="string">'authorization_code'</span>,</span><br><span class="line">     ];</span><br><span class="line"></span><br><span class="line">     $signStr = $<span class="keyword">this</span>-&gt;myHttpBuildQuery($infoArr);</span><br><span class="line">     $sign = urlencode($<span class="keyword">this</span>-&gt;enRSA2($signStr));</span><br><span class="line">     $qureStr = $signStr.<span class="string">'&amp;sign='</span>.$sign;</span><br><span class="line"></span><br><span class="line">     $res = <span class="keyword">new</span> Client();</span><br><span class="line">     $body = $res-&gt;get(<span class="string">'https://openapi.alipay.com/gateway.do?'</span>.$qureStr)-&gt;getBody()-&gt;getContents();</span><br><span class="line">     $body = json_decode($body);</span><br><span class="line">     <span class="keyword">if</span> (!isset($body-&gt;alipay_system_oauth_token_response-&gt;access_token)) &#123;</span><br><span class="line">         <span class="keyword">return</span> <span class="string">'接口异常'</span>;</span><br><span class="line">     &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">         $autho_token = $body-&gt;alipay_system_oauth_token_response-&gt;access_token;</span><br><span class="line">         $userinfo = $<span class="keyword">this</span>-&gt;aliPayUserInfo($autho_token);</span><br><span class="line">         <span class="keyword">return</span> $userinfo; <span class="comment">// 或则 返回 json_encode($userinfo) 根据实际需求来 </span></span><br><span class="line">     &#125;</span><br><span class="line"> &#125;</span><br><span class="line"></span><br><span class="line"> <span class="comment">/**</span></span><br><span class="line"><span class="comment">  * AliPayUserInfo 通过 token 获取用户信息</span></span><br><span class="line"><span class="comment">  */</span></span><br><span class="line"> private <span class="function"><span class="keyword">function</span> <span class="title">aliPayUserInfo</span>(<span class="params">$autho_token</span>)</span></span><br><span class="line"><span class="function"> </span>&#123;</span><br><span class="line">     $infoArr = [</span><br><span class="line">         <span class="string">'method'</span> =&gt; <span class="string">'alipay.user.info.share'</span>,</span><br><span class="line">         <span class="string">'app_id'</span> =&gt; $<span class="keyword">this</span>-&gt;app_id,</span><br><span class="line">         <span class="string">'charset'</span> =&gt; <span class="string">'utf-8'</span>,</span><br><span class="line">         <span class="string">'sign_type'</span> =&gt; <span class="string">'RSA2'</span>,</span><br><span class="line">         <span class="string">'timestamp'</span> =&gt; date(<span class="string">'Y-m-d H:i:s'</span>),</span><br><span class="line">         <span class="string">'version'</span> =&gt; <span class="string">'1.0'</span>,</span><br><span class="line">         <span class="string">'auth_token'</span> =&gt; $autho_token,</span><br><span class="line">     ];</span><br><span class="line"></span><br><span class="line">     $signStr = $<span class="keyword">this</span>-&gt;myHttpBuildQuery($infoArr);</span><br><span class="line">     $sign = urlencode($<span class="keyword">this</span>-&gt;enRSA2($signStr));</span><br><span class="line">     $qureStr = $signStr.<span class="string">'&amp;sign='</span>.$sign;</span><br><span class="line"></span><br><span class="line">     $res = <span class="keyword">new</span> Client();</span><br><span class="line">     $body = $res-&gt;get(<span class="string">'https://openapi.alipay.com/gateway.do?'</span>.$qureStr)-&gt;getBody()-&gt;getContents();</span><br><span class="line">     $body = json_decode($body);</span><br><span class="line">     <span class="keyword">if</span> (!isset($body-&gt;alipay_user_info_share_response)) &#123;</span><br><span class="line">         <span class="keyword">return</span> <span class="string">'接口异常'</span>;</span><br><span class="line">     &#125;</span><br><span class="line">     $body = $body-&gt;alipay_user_info_share_response;</span><br><span class="line">     <span class="keyword">return</span> $body;</span><br><span class="line"> &#125;</span><br><span class="line"> https:<span class="comment">//learnku.com/articles/30076#replies</span></span><br></pre></td></tr></table></figure>
<h3 id="树状数据结构存储方式"><a href="#树状数据结构存储方式" class="headerlink" title="树状数据结构存储方式"></a>树状数据结构存储方式</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE <span class="string">`categories`</span> (</span><br><span class="line">  <span class="string">`id`</span> int(<span class="number">11</span>) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  <span class="string">`title`</span> char(<span class="number">100</span>) NOT NULL,</span><br><span class="line">  <span class="string">`pid`</span> int(<span class="number">11</span>) DEFAULT <span class="number">0</span>,</span><br><span class="line">  PRIMARY KEY (<span class="string">`id`</span>)</span><br><span class="line">) ENGINE=InnoDB;</span><br><span class="line">CREATE TABLE <span class="string">`categories`</span> (</span><br><span class="line">  <span class="string">`id`</span> int(<span class="number">11</span>) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  <span class="string">`title`</span> char(<span class="number">100</span>) NOT NULL,</span><br><span class="line">  <span class="string">`lft`</span> int(<span class="number">11</span>) NOT NULL UNIQUE CHECK (lft&gt; <span class="number">0</span>),</span><br><span class="line">  <span class="string">`rgt`</span> int(<span class="number">11</span>) NOT NULL UNIQUE CHECK (rgt&gt; <span class="number">1</span>),</span><br><span class="line">  PRIMARY KEY (<span class="string">`id`</span>)</span><br><span class="line">) ENGINE=InnoDB;</span><br><span class="line">lft 和 rgt 是作为集合的边界，两者差值越大，则集合越大，里面的元素就越多。</span><br><span class="line">根据子集，查找父级的分类</span><br><span class="line"></span><br><span class="line">SELECT c2.* </span><br><span class="line">  FROM categories <span class="keyword">as</span> c1, categories <span class="keyword">as</span> c2</span><br><span class="line">  WHERE c1.lft BETWEEN c2.lft and c2.rgt </span><br><span class="line">      AND c1.title = <span class="string">'华为'</span>;</span><br><span class="line"></span><br><span class="line">+----+-------------+-----+-----+</span><br><span class="line">| id | title       | lft | rgt |</span><br><span class="line">+----+-------------+-----+-----+</span><br><span class="line">|  <span class="number">1</span> | Smartphones |   <span class="number">1</span> |  <span class="number">14</span> |</span><br><span class="line">|  <span class="number">5</span> | Harmony OS  |  <span class="number">10</span> |  <span class="number">13</span> |</span><br><span class="line">|  <span class="number">8</span> | 华为        |  <span class="number">11</span> |  <span class="number">12</span> |</span><br><span class="line">+----+-------------+-----+-----+</span><br><span class="line">根据父级，查找其底下所有的子集</span><br><span class="line"></span><br><span class="line">SELECT c1.*</span><br><span class="line">   FROM categories AS c1, categories AS c2</span><br><span class="line">  WHERE c1.lft BETWEEN c2.lft AND c2.rgt</span><br><span class="line">    AND c2.title = <span class="string">'Smartphones'</span>;</span><br><span class="line"></span><br><span class="line">+----+-------------+-----+-----+</span><br><span class="line">| id | title       | lft | rgt |</span><br><span class="line">+----+-------------+-----+-----+</span><br><span class="line">|  <span class="number">1</span> | Smartphones |   <span class="number">1</span> |  <span class="number">14</span> |</span><br><span class="line">|  <span class="number">3</span> | Android     |   <span class="number">2</span> |   <span class="number">5</span> |</span><br><span class="line">|  <span class="number">4</span> | iOS         |   <span class="number">6</span> |   <span class="number">9</span> |</span><br><span class="line">|  <span class="number">5</span> | Harmony OS  |  <span class="number">10</span> |  <span class="number">13</span> |</span><br><span class="line">|  <span class="number">6</span> | 小米        |   <span class="number">3</span> |   <span class="number">4</span> |</span><br><span class="line">|  <span class="number">7</span> | iPhone      |   <span class="number">7</span> |   <span class="number">8</span> |</span><br><span class="line">|  <span class="number">8</span> | 华为        |  <span class="number">11</span> |  <span class="number">12</span> |</span><br><span class="line">+----+-------------+-----+-----+</span><br><span class="line">查看各个分类的级别</span><br><span class="line"></span><br><span class="line"> SELECT COUNT(c2.id) AS indentation, c1.title</span><br><span class="line">  FROM categories AS c1, categories AS c2下周三we<span class="string">'fv</span></span><br><span class="line"><span class="string">  WHERE c1.lft BETWEEN c2.lft AND c2.rgt</span></span><br><span class="line"><span class="string">  GROUP BY c1.title</span></span><br><span class="line"><span class="string">  ORDER BY c1.lft;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">+-------------+-------------+</span></span><br><span class="line"><span class="string">| indentation | title       |</span></span><br><span class="line"><span class="string">+-------------+-------------+</span></span><br><span class="line"><span class="string">|           1 | Smartphones |</span></span><br><span class="line"><span class="string">|           2 | Android     |</span></span><br><span class="line"><span class="string">|           3 | 小米        |</span></span><br><span class="line"><span class="string">|           2 | iOS         |</span></span><br><span class="line"><span class="string">|           3 | iPhone      |</span></span><br><span class="line"><span class="string">|           2 | Harmony OS  |</span></span><br><span class="line"><span class="string">|           3 | 华为        |</span></span><br><span class="line"><span class="string">+-------------+-------------+</span></span><br><span class="line"><span class="string">https://learnku.com/articles/33630</span></span><br></pre></td></tr></table></figure>
<p><a href="https://github.com/FireLustre/php-dfa-sensitive" target="_blank" rel="noopener">敏感词过滤 </a></p>
<p><a href="https://learnku.com/articles/33646" target="_blank" rel="noopener">PHP 中基于 Casbin 做 RBAC + RESTful 权限控制</a></p>
<p><a href="https://github.com/k9606/kxcel" target="_blank" rel="noopener">方便导入和导出 Excel</a></p>
<p><a href="https://learnku.com/articles/33537" target="_blank" rel="noopener">windows10 swoole laravel</a></p>
<p><a href="https://learnku.com/articles/25440" target="_blank" rel="noopener">Windows 系统下的 Linux 子系统</a></p>
<p><a href="https://learnku.com/articles/30407" target="_blank" rel="noopener">【系统】打造自己最喜爱的 Windows10 —— U 盘启动盘制作篇</a></p>
<p><a href="https://learnku.com/articles/32848" target="_blank" rel="noopener"> sentry 追踪 Laravel 生产环境 bug</a></p>
<p><a href="https://learnku.com/articles/25478" target="_blank" rel="noopener">尝试 Leetcode</a></p>
<p><a href="https://github.com/aliliin/LeetCode-Algorithms" target="_blank" rel="noopener">LeetCode-Algorithms 算法题 PHP 实现</a></p>
<p><a href="https://github.com/aliliin/LeetCode-database-problemset" target="_blank" rel="noopener">Leetcode database problem 数据库练习题</a></p>
<p><a href="https://learnku.com/articles/28607" target="_blank" rel="noopener">PHP 与 Swoole 浅析与学习</a></p>
<p><a href="https://laragon.org/" target="_blank" rel="noopener">PHP开发环境laragon</a></p>
<p><a href="https://www.easyswoole.com/Cn/Video/income.html" target="_blank" rel="noopener">php swoole视频</a></p>
<p><a href="https://learnku.com/articles/13472/teach-you-how-to-use-php-to-generate-pdf-and-image-gracefully" target="_blank" rel="noopener">教你如何使用 PHP 优雅的生成 PDF 和 Image</a></p>
<p><a href="https://learnku.com/articles/25922?order_by=vote_count&amp;" target="_blank" rel="noopener">使用 Laravel-snappy 生成 PDF 踩坑记录</a></p>
<p><a href="https://segmentfault.com/a/1190000018765575" target="_blank" rel="noopener">初识wkhtmltopdf</a></p>
<p><a href="https://github.com/zmecust/learning-manual" target="_blank" rel="noopener">个人学习记录</a></p>
<p><a href="https://www.phpliveregex.com/" target="_blank" rel="noopener">PHP 的在线正则表达式</a></p>
<p><a href="https://alpha2016.github.io/2019/03/06/%E4%BC%98%E5%8C%96Nginx%E5%92%8CPHP-fpm%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E5%BC%8F/" target="_blank" rel="noopener">优化Nginx及PHP-fpm的几种方式</a></p>
<p><a href="https://learnku.com/articles/33189" target="_blank" rel="noopener">php注释标记</a></p>
<p><a href="https://php1024.com/posts/45.htm" target="_blank" rel="noopener">PHP使用Dompdf</a></p>
<p><a href="https://learnku.com/articles/33320" target="_blank" rel="noopener">CentOS 下多版本 PHP 的安装与配置</a></p>
<p><a href="https://github.com/jesseduffield/lazydocker" target="_blank" rel="noopener">终端显示你的 docker 状态</a></p>
<p><a href="https://learnku.com/articles/32416" target="_blank" rel="noopener">复杂度分享</a></p>
<p><a href="https://learnku.com/articles/32025" target="_blank" rel="noopener">Laravel-admin 源码分析系列</a></p>
<p><a href="https://learnku.com/articles/32699" target="_blank" rel="noopener">Laravel 如何实现数据的软删除</a></p>
<p><a href="https://github.com/alicfeng/TeamStandard/tree/master/book/PHP" target="_blank" rel="noopener">PHP开发规范单元测试</a></p>
<p><a href="http://cuihuan.net/2019/05/12/%E5%AD%97%E7%AC%A6%E7%BC%96%E7%A0%81%E9%82%A3%E4%BA%9B%E4%BA%8B%E5%84%BF/" target="_blank" rel="noopener">字符编码那些事儿</a></p>
<p><a href="https://github.com/alicfeng/TeamStandard" target="_blank" rel="noopener">基于 gitbook 构建团队项目开发规范文档</a></p>
<p><a href="https://post.zz173.com/detail/lq150Y4PnNNnyG_RwtyRCw.html" target="_blank" rel="noopener">PHP深入pack/unpack</a></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/12/那些你可能用得上的简历写作工具/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/08/12/那些你可能用得上的简历写作工具/" itemprop="url">那些你可能用得上的简历写作工具</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-12T20:32:52+08:00">
                2019-08-12
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  865 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  3 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>马上要到金九银十的招聘季节了，很多人又要开始找工作了，除了简历上充实的干货之外，更重要的就是写一份漂亮的简历了。</p>
<p>通常简历用 pdf 格式最好，因为PDF不可编辑，浏览器就能打开，不用担心像Word那样不同操作系统的兼容问题。</p>
<p>这里推荐几个非常赞的简历写作工具。</p>
<h3 id="冷熊简历"><a href="#冷熊简历" class="headerlink" title="冷熊简历"></a>冷熊简历</h3><p>冷熊简历是一个运行在浏览器里边的 Markdown 编辑器， 支持 Markdown 实时预览并保存，下载 MD 文件，可以一键生成 PDF ，提供简单大方的单页式排版。   网址 <a href="http://cv.ftqq.com/#" target="_blank" rel="noopener">http://cv.ftqq.com/#</a>   , 我上次找到新浪的工作就是用的这个来写简历的</p>
<p>作者easy还提供了Mac版   <a href="https://share.weiyun.com/5AvnFvu。" target="_blank" rel="noopener">https://share.weiyun.com/5AvnFvu。</a></p>
<p>如果你还不会markdown，欢迎查看之前的文章学习下，10分钟学会。<a href="https://mp.weixin.qq.com/s/TuJIqv5wv27avFKG8zmJUQ" target="_blank" rel="noopener">我是如何用 Markdown 写公众号文章的</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-3609b6a7baf23ac5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>生成pdf效果见如图，然后可以直接下载到本地发给hr了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-77c3258d694cf9fe.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>作者还提供了程序员简历模板系列，包括PHP，iOS ，安卓，前端等。<a href="https://github.com/geekcompany/ResumeSample" target="_blank" rel="noopener">https://github.com/geekcompany/ResumeSample</a>  </p>
<p>如果你不是程序员，可以找份你对应岗位的模板，粘贴到这里即可。</p>
<p>为了方便使用，作者还拍了个视频来介绍，见微博地址 <a href="https://weibo.com/1088413295/Fw6fNfSkA" target="_blank" rel="noopener">https://weibo.com/1088413295/Fw6fNfSkA</a> </p>
<h3 id="极简简历"><a href="#极简简历" class="headerlink" title="极简简历"></a>极简简历</h3><p> 这是一个在线制作简历的网站，支持免费在线制作导出图片， pdf， word，还有免费简历模板下载，网址 <a href="http://www.polebrief.com/" target="_blank" rel="noopener">http://www.polebrief.com/</a></p>
<p>有各种岗位的内容模板。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-bd2f847009a42e1b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>可以在线预览效果，并下载PDF。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-59a6ff537ea1af38.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>如果以上还不能满足你的需求，可以使用专业的简历工具，比如超级简历，五百丁什么的，当然那些是收费的，并且不便宜。</p>
<p>最后如果你是应届生，想进入新浪的话可以使用我的内推码 <code>JO3A7</code>。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-0ad290218d13eb8c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>资源：<br>简历模板<a href="http://ftqq.com/book/proguide/vol4/w312.html#其他项目-2" target="_blank" rel="noopener">http://ftqq.com/book/proguide/vol4/w312.html#其他项目-2</a><br>哪里有免费优秀简历模板下载<a href="https://www.zhihu.com/question/49065128" target="_blank" rel="noopener">https://www.zhihu.com/question/49065128</a><br>有哪些优秀的简历模板<a href="https://www.zhihu.com/question/23734172" target="_blank" rel="noopener">https://www.zhihu.com/question/23734172</a><br> 超级简历<a href="http://WonderCV.com" target="_blank" rel="noopener">http://WonderCV.com</a><br>用 Markdown 维护简历，用 GitHub Page 托管。<a href="https://github.com/hackjutsu/geek-profile" target="_blank" rel="noopener">https://github.com/hackjutsu/geek-profile</a><br>简历调成一页纸<a href="https://zhuanlan.zhihu.com/p/26781612" target="_blank" rel="noopener">https://zhuanlan.zhihu.com/p/26781612</a><br>简历常用例句<a href="https://github.com/resumejob/awesome-resume" target="_blank" rel="noopener">https://github.com/resumejob/awesome-resume</a><br>中英混排  <a href="https://github.com/mzlogin/chinese-copywriting-guidelines" target="_blank" rel="noopener">https://github.com/mzlogin/chinese-copywriting-guidelines</a><br><a href="http://resume.github.io/" target="_blank" rel="noopener">http://resume.github.io/</a><br><a href="https://docs.google.com/document/u/0/" target="_blank" rel="noopener">谷歌文档在线可以制作PDF</a><br>牛人简历<a href="https://pennyliang.com/#/penny" target="_blank" rel="noopener">https://pennyliang.com/#/penny</a><br> 适合程序员/设计师的简历模板 <a href="https://github.com/byoungd/Resume-template-for-Coder" target="_blank" rel="noopener">https://github.com/byoungd/Resume-template-for-Coder</a><br>适合中文的简历模板收集 <a href="https://github.com/dyweb/awesome-resume-for-chinese" target="_blank" rel="noopener">https://github.com/dyweb/awesome-resume-for-chinese</a><br>互联网从业者简历翻译指南v1.0  <a href="https://weibo.com/ttarticle/p/show?id=2309404385625242506061" target="_blank" rel="noopener">https://weibo.com/ttarticle/p/show?id=2309404385625242506061</a><br>教你怎么制作优秀简历，经验贴合集 <a href="https://weibo.com/5888006271/HAQyvCoFc" target="_blank" rel="noopener">https://weibo.com/5888006271/HAQyvCoFc</a><br><a href="https://qcrao.com/2019/07/08/how-to-write-resume-gracefully/" target="_blank" rel="noopener">https://qcrao.com/2019/07/08/how-to-write-resume-gracefully/</a><br><a href="https://www.zhiyeapp.com/" target="_blank" rel="noopener">https://www.zhiyeapp.com/</a><br><a href="https://www.500d.me/" target="_blank" rel="noopener">https://www.500d.me/</a><br><a href="http://www.jianliben.com/" target="_blank" rel="noopener">http://www.jianliben.com/</a><br><a href="https://github.com//0voice/interview_internal_reference" target="_blank" rel="noopener">2019年最新总结，阿里，腾讯，百度，美团，头条等技术面试题目，以及答案，专家出题人分析汇总</a><br><a href="https://github.com/billryan/resume" target="_blank" rel="noopener">https://github.com/billryan/resume</a><br> letex 模板<a href="https://github.com/dnl-blkv/mcdowell-cv" target="_blank" rel="noopener">https://github.com/dnl-blkv/mcdowell-cv</a>  </p>
<p> 推荐阅读：</p>
<p><a href="https://mp.weixin.qq.com/s/TuJIqv5wv27avFKG8zmJUQ" target="_blank" rel="noopener">我是如何用 Markdown 写公众号文章的</a></p>
<p><a href="https://mp.weixin.qq.com/s/Xz1m-mqtCcBF_4hmGCpkUQ" target="_blank" rel="noopener">如何发一条空白的朋友圈</a></p>
<p><a href="https://mp.weixin.qq.com/s/MsK-yZfYP0Kwjtg_f4GWZQ" target="_blank" rel="noopener">历史上消失的那 10 天去哪了？</a></p>
<p><a href="https://mp.weixin.qq.com/s/y8BrtwH4vlXlHKWQ9OMhdw" target="_blank" rel="noopener">听说你想 520 表白</a></p>
<p><a href="https://mp.weixin.qq.com/s/_3AeNahwbs8c3UJ0is1t4A" target="_blank" rel="noopener">如何在电脑上登陆多个微信</a></p>
<p><a href="https://mp.weixin.qq.com/s/qyFvOgHf1mXwPKO0tQwUyg" target="_blank" rel="noopener">如何提取公积金 9 天到账</a></p>
<p><a href="https://mp.weixin.qq.com/s/MOSo-SHTz1zaJaXQM3tnqg" target="_blank" rel="noopener">上班摸鱼好去处</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-393b26173c148690.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="免费星球"></p>
<h3 id="公众号：苏生不惑"><a href="#公众号：苏生不惑" class="headerlink" title="公众号：苏生不惑"></a>公众号：苏生不惑</h3><p> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/06/我是如何用-Markdown-写公众号文章的/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/08/06/我是如何用-Markdown-写公众号文章的/" itemprop="url">我是如何用 Markdown 写公众号文章的</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-06T20:04:21+08:00">
                2019-08-06
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.5k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  5 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>工欲善其事，必先利其器，想快速完美的完成一篇文章，编辑器和排版是很重要的，这里强烈推荐下 Markdown。</p>
<blockquote>
<p>Markdown是一种轻量级标记语言，创始人为约翰·格鲁伯（英语：John Gruber）。它允许人们“使用易读易写的纯文本格式编写文档，然后转换成有效的XHTML（或者HTML）文档”。</p>
</blockquote>
<p>以上介绍来自维基百科 <a href="https://zh.wikipedia.org/wiki/Markdown" target="_blank" rel="noopener">https://zh.wikipedia.org/wiki/Markdown</a></p>
<p>Markdown 相比普通的文本编辑器有什么优点呢？</p>
<ul>
<li>如同编辑 word 一样编辑 Markdown 文件，简单直观。</li>
<li>轻松插入图片（直接粘贴上传）、表格、链接、列表、流程图、甘特图、时序图、LaTeX 公式等。</li>
<li>高亮代码块。</li>
<li>支持实时预览。</li>
<li>表格编辑。</li>
</ul>
<p>使用 Markdown 编辑器写文章，可以让作者只专注于内容，不再操心排版的问题。</p>
<p>公众号后台是有编辑器的，但比较难用，而且经常停留时间久了（文章写得长）可能需要重新登录，更麻烦的是排版问题，还没法实时预览效果。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-e6cf65321c4e9d02.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>所以我一直是用markdown编辑器写好文章，然后直接粘贴到公众号编辑器里，本文也是在 markdown 下编辑的。</p>
<p>下面说说 Markdown 语法 怎么用的，其实很简单，10分钟学会。</p>
<h3 id="常用语法"><a href="#常用语法" class="headerlink" title="常用语法"></a>常用语法</h3><h6 id="标题"><a href="#标题" class="headerlink" title="标题"></a>标题</h6><p>语法：<code>#+空格+文本</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># 一级标题</span><br><span class="line">## 二级标题</span><br><span class="line">### 三级标题</span><br><span class="line">#### 四级标题</span><br><span class="line">##### 五级标题</span><br><span class="line">###### 六级标题</span><br></pre></td></tr></table></figure>
<p>效果：<br><img src="https://upload-images.jianshu.io/upload_images/17817191-8ac42fd3a6cc261b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>可以看到三级标题比六级标题字体要大粗。</p>
<h6 id="插入链接"><a href="#插入链接" class="headerlink" title="插入链接"></a>插入链接</h6><p>语法：<code>[文字描述](文字链接)</code><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[Markdown中文文档](https://markdown-zh.readthedocs.io/en/latest/)</span><br></pre></td></tr></table></figure></p>
<p>效果：<br><a href="https://markdown-zh.readthedocs.io/en/latest/" target="_blank" rel="noopener">Markdown中文文档</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-afb00ff80acff35f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h6 id="插入图片"><a href="#插入图片" class="headerlink" title="插入图片"></a>插入图片</h6><p>语法：!<code>[图片描述(图片链接)</code><br>简单点就是直接复制图片后粘贴上传。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">![Markdown中文文档](https://upload-images.jianshu.io/upload_images/17817191-2cfc5cfb11272656.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)</span><br></pre></td></tr></table></figure></p>
<p>效果：<br><img src="https://upload-images.jianshu.io/upload_images/17817191-2691d0eac427844c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h6 id="引用"><a href="#引用" class="headerlink" title="引用"></a>引用</h6><p>语法： <code>&gt;+空格 +文本</code><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&gt; 这是一段引用</span><br></pre></td></tr></table></figure></p>
<p>效果：</p>
<blockquote>
<p>这是一段引用<br>这是另一段引用</p>
</blockquote>
<h6 id="代码块"><a href="#代码块" class="headerlink" title="代码块"></a>代码块</h6><p>语法如下：</p>
<p> \<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"> 这是代码段</span><br><span class="line">\</span><br></pre></td></tr></table></figure></p>
<p>效果：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">public <span class="function"><span class="keyword">function</span> <span class="title">cache</span>(<span class="params"></span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">        $cache = \Cache::get(<span class="string">'app'</span>);</span><br><span class="line">        <span class="keyword">if</span>(!$cache) &#123;</span><br><span class="line">            \Cache::put(<span class="string">'app'</span>, <span class="string">'cache'</span>, <span class="number">1</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        dump($cache);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<h6 id="LaTeX公式"><a href="#LaTeX公式" class="headerlink" title="LaTeX公式"></a>LaTeX公式</h6><p>行内公式，使用两个美元符 <code>$$</code> 包裹 <code>LaTeX</code> 格式的数学公式 ，如<br> <code>$$\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$$</code></p>
<p>效果：<br>$$\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$$<br>或者块级公式<code>$$    x = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$</code>：</p>
<p>$$    x = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$</p>
<p>因为公众号不支持公式，所以用图片替代了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-bf3e6ecf1d5bb5a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h6 id="表格"><a href="#表格" class="headerlink" title="表格"></a>表格</h6><p>语法如下：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">| 项目        | 价格   |  数量  |</span><br><span class="line">| --------   | -----:  | :----:  |</span><br><span class="line">| 电脑     | \$1600 |   6     |</span><br><span class="line">| 手机        |   \$120   |   8   |</span><br></pre></td></tr></table></figure></p>
<p>效果：</p>
<table>
<thead>
<tr>
<th>项目</th>
<th style="text-align:right">价格</th>
<th style="text-align:center">数量</th>
</tr>
</thead>
<tbody>
<tr>
<td>电脑</td>
<td style="text-align:right">\$1600</td>
<td style="text-align:center">6</td>
</tr>
<tr>
<td>手机</td>
<td style="text-align:right">\$120</td>
<td style="text-align:center">8</td>
</tr>
</tbody>
</table>
<h6 id="列表"><a href="#列表" class="headerlink" title="列表"></a>列表</h6><p>语法： - + 空格  ＋ 文本   <code>或者</code> 数字  +  + 空格 + 文本<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">- 列表一</span><br><span class="line">- 列表二</span><br><span class="line">- 列表三</span><br></pre></td></tr></table></figure></p>
<p>效果：</p>
<ul>
<li>列表一</li>
<li>列表二</li>
<li>列表三</li>
</ul>
<h6 id="粗体、斜体、删除线"><a href="#粗体、斜体、删除线" class="headerlink" title="粗体、斜体、删除线"></a>粗体、斜体、删除线</h6><p>语法：<code>*文字*</code><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">**粗体**   *斜体*  ~~删除线~~</span><br></pre></td></tr></table></figure></p>
<p>效果：<br><strong>粗体</strong>   <em>斜体</em>  <del>删除线</del></p>
<h6 id="转义"><a href="#转义" class="headerlink" title="转义"></a>转义</h6><p>如果你想只显示一个 <code>#</code> 号而不是一个标记，可以这样输入<code>\# Markdown</code> 就不会误认为是一个标记了。<br>语法：<code>\#</code></p>
<p>效果：<br># Markdown</p>
<p>以上是常用的语法，应该能完全应付写一篇文章，如果想了解更多语法可以到Markdown中文文档<a href="https://markdown-zh.readthedocs.io/en/latest/查看。" target="_blank" rel="noopener">https://markdown-zh.readthedocs.io/en/latest/查看。</a></p>
<h3 id="在线markdown编辑器"><a href="#在线markdown编辑器" class="headerlink" title="在线markdown编辑器"></a>在线markdown编辑器</h3><p>知道了markdown 语法，实践才是硬道理，学习 markdown 是个很轻松的过程，因为能实时预览，10分钟就能学好，赶紧来试试吧。</p>
<p>目前很多网站支持 markdown 了，比如简书，简书一个很不错的博客平台，提供富文本编辑器和markdown编辑器，先将markdown编辑器设置为默认。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-950bf4075801b416.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>它能实时预览保存。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-c5a687064664a493.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>还能查看文件编辑历史，如果想回到过去某个版本也很简单。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-d23bc8581daccb60.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>不过简书需要注册账号，如果是临时用用推荐作业部落<a href="https://www.zybuluo.com/mdeditor" target="_blank" rel="noopener">https://www.zybuluo.com/mdeditor</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-03b3c58bd51da620.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="客户端markdown编辑器"><a href="#客户端markdown编辑器" class="headerlink" title="客户端markdown编辑器"></a>客户端markdown编辑器</h3><p>除了在线的 markdown编辑器，还有客户端版本的markdown编辑器，这样就能本地编辑，不需要联网也能使用markdown，Markdown文件的后缀名是<code>.md</code>。</p>
<p>首先推荐免费极简编辑器Typora  <a href="https://typora.io/" target="_blank" rel="noopener">https://typora.io/</a> 支持的平台有 Windows、MacOS、Linux。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-55671777537d1f63.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图来自简书作者毕小烦"></p>
<p>另外一个更懂程序员的markdown软件vnote   <a href="https://tamlok.github.io/vnote/zh_cn/#!downloads.md" target="_blank" rel="noopener">https://tamlok.github.io/vnote/zh_cn/#!downloads.md</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-86d443ea9f033e45.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="vnote"></p>
<h3 id="公众号编辑器"><a href="#公众号编辑器" class="headerlink" title="公众号编辑器"></a>公众号编辑器</h3><p> 用markdown编辑器写完文章后，如果直接复制到公众号编辑器，因为公众号后台支持markdown不大好，效果可能会很乱。</p>
<p>所以有人开发了针对公众号后台的markdown编辑器，比如<a href="https://lab.lyric.im/wxformat和http://js8.in/mpeditor，" target="_blank" rel="noopener">https://lab.lyric.im/wxformat和http://js8.in/mpeditor，</a> 这2个是开源的，可以部署到自己服务器。</p>
<p>不过我常用的是<a href="http://md.aclickall.com/" target="_blank" rel="noopener">http://md.aclickall.com/</a> ，将markdown复制到这然后粘贴到公众号后台就完成了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-8c55e4bfa052028a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>更多资源：<br>MarkDown工具<a href="https://www.ifuntools.cn/special/markdown/" target="_blank" rel="noopener">https://www.ifuntools.cn/special/markdown/</a><br>在线脑图工具<a href="https://www.socialwiki.cn/" target="_blank" rel="noopener">https://www.socialwiki.cn/</a><br><a href="https://www.mdeditor.com/" target="_blank" rel="noopener">https://www.mdeditor.com/</a><br><a href="https://help.seafile.com/zh/wiki/markdown_editor.html" target="_blank" rel="noopener">https://help.seafile.com/zh/wiki/markdown_editor.html</a><br><a href="https://mazhuang.org/2018/09/06/markdown-intro/" target="_blank" rel="noopener">https://mazhuang.org/2018/09/06/markdown-intro/</a><br><a href="https://coding.net/help/doc/project/markdown.html" target="_blank" rel="noopener">https://coding.net/help/doc/project/markdown.html</a><br><a href="https://maxiang.io/" target="_blank" rel="noopener">https://maxiang.io/</a><br><a href="https://juejin.im/post/5c1cd16de51d4563d9206173" target="_blank" rel="noopener">https://juejin.im/post/5c1cd16de51d4563d9206173</a><br>基于 git 的笔记软件  <a href="https://www.gitnoteapp.com/" target="_blank" rel="noopener">https://www.gitnoteapp.com/</a><br>有道云笔记<a href="http://note.youdao.com/" target="_blank" rel="noopener">http://note.youdao.com/</a><br><a href="https://github.com/lyricat/wechat-format" target="_blank" rel="noopener">https://github.com/lyricat/wechat-format</a><br><a href="https://www.mdnice.com/" target="_blank" rel="noopener">https://www.mdnice.com/</a></p>
<p>你平常用的哪个编辑器，可以评论分享下。</p>
<p>推荐阅读：</p>
<p><a href="https://mp.weixin.qq.com/s/Xz1m-mqtCcBF_4hmGCpkUQ" target="_blank" rel="noopener">如何发一条空白的朋友圈</a></p>
<p><a href="https://mp.weixin.qq.com/s/_3AeNahwbs8c3UJ0is1t4A" target="_blank" rel="noopener">如何在电脑上登陆多个微信</a></p>
<p><a href="https://mp.weixin.qq.com/s/-cSjrvkibYGp5Fx8gCTFuw" target="_blank" rel="noopener">那些你可能不知道的浏览器奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/eGDO0Y8el_dsEyriCoAgog" target="_blank" rel="noopener">那些你可能不知道的微信奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/j7VhoZXmUTnOWC5C_B8jlQ" target="_blank" rel="noopener">那些你可能不知道的微博奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/LtI2piwAIDXA590NEsXvuw" target="_blank" rel="noopener">那些你可能不知道的网易云音乐奇技淫巧</a></p>
<p> <a href="https://mp.weixin.qq.com/s/-5tZWfeWWa_E8jRCH0T_Cw" target="_blank" rel="noopener">那些你可能不知道的搜索奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/5InOxKmi9eXk33G_8N3byQ" target="_blank" rel="noopener">那些你可能不知道的视频下载奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/R3x-xZwqLIVwPjlgikDQ9A" target="_blank" rel="noopener">那些你可能不知道的免费观看 VIP 视频奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/sqRgMh4rxFBt5YxNtaa6dw" target="_blank" rel="noopener">那些你可能不知道的知乎奇技淫巧</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-393b26173c148690.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="免费星球"></p>
<h3 id="公众号：苏生不惑"><a href="#公众号：苏生不惑" class="headerlink" title="公众号：苏生不惑"></a>公众号：苏生不惑</h3><p> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/06/如何发一条空白的朋友圈/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/08/06/如何发一条空白的朋友圈/" itemprop="url">如何发一条空白的朋友圈</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-06T20:03:27+08:00">
                2019-08-06
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  993 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  3 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>所谓空白的朋友圈就是一条看起来没有文字的朋友圈，因为发朋友圈的时候不输入文字是没法发送的。不可见字符是有文字内容的，只是人的肉眼看不见，所以相当于空白。</p>
<h3 id="不可见字符"><a href="#不可见字符" class="headerlink" title="不可见字符"></a>不可见字符</h3><p>不可见字符就是零宽空格，见维基百科解释<a href="https://zh.wikipedia.org/wiki/%E9%9B%B6%E5%AE%BD%E7%A9%BA%E6%A0%BC" target="_blank" rel="noopener">https://zh.wikipedia.org/wiki/%E9%9B%B6%E5%AE%BD%E7%A9%BA%E6%A0%BC</a><br>：</p>
<blockquote>
<p>零宽空格（zero-width space, ZWSP）是一种不可打印的Unicode字符，用于可能需要换行处。</p>
</blockquote>
<p><a href="http://www.fileformat.info/info/unicode/category/Mn/list.htm" target="_blank" rel="noopener">http://www.fileformat.info/info/unicode/category/Mn/list.htm</a> 这里列出了许多不可见字符，控制台输入对应的Unicode码就能显示出来。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-a5d76abc5cc0f5a0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>比如第一个 <code>\u0300</code> 就是<code>̀</code>这个字符，但是这个字符肉眼是看不见的。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-3c2b1e3601144d3b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>通过进制转换可以看到它的二进制是<code>00000000</code><br><img src="https://upload-images.jianshu.io/upload_images/17817191-6e7938ce9d6a1364.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>在PHP里可以看到它的长度为2<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&gt;&gt;&gt; strlen(<span class="string">'̀'</span>)</span><br><span class="line">=&gt; <span class="number">2</span></span><br></pre></td></tr></table></figure></p>
<h3 id="空白朋友圈"><a href="#空白朋友圈" class="headerlink" title="空白朋友圈"></a>空白朋友圈</h3><p>将上面copy的不可见字符发到朋友圈 ，效果如下：<br><img src="https://upload-images.jianshu.io/upload_images/17817191-54d98f006b6bfc9e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>如果你也想发条空白的朋友圈，在公众号内回复  朋友圈  获取,当然微博也是可以的<a href="https://weibo.com/2717930601/HDjs3fVkU" target="_blank" rel="noopener">https://weibo.com/2717930601/HDjs3fVkU</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-7f48ac1c43cfb7d9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>星球一样：<br><img src="https://upload-images.jianshu.io/upload_images/17817191-e5f66ace53a0ffc1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="有意思的字符"><a href="#有意思的字符" class="headerlink" title="有意思的字符"></a>有意思的字符</h3><p><a href="https://www.compart.com/en/unicode/category/So" target="_blank" rel="noopener">https://www.compart.com/en/unicode/category/So</a> 和 <a href="https://unicode-table.com/cn/#lao" target="_blank" rel="noopener">https://unicode-table.com/cn/#lao</a> 这里列出了一些有意思的字符。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-0335fa58f90f77b5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-36459f0c83042320.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>比如手表 ⌚ ,版权 ℗ ，商标 ™ ， 箭头 ↱，键盘 ⌨ 等，在控制台输入’\u231a’就是手表。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-7db6002f089ecf44.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>上面的字符是没法用输入法直接输入的，所以搜狗输入法也提供了一些特殊字符。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-f7c61fe3f39d3e72.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p> 其中这个<code>é</code>字符，  unicode 是 <code>\u00e9</code>, 而 ‘\u0301’ 是个不可见字符，<br> ‘e’ + ‘\u0301’ 拼在一起就成了这样。<code>e</code>的长度为1，拼接后长度为2，见 <a href="https://www.cnblogs.com/52cik/p/unicode-mark-nonspacing.html。" target="_blank" rel="noopener">https://www.cnblogs.com/52cik/p/unicode-mark-nonspacing.html。</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-d50b23e7e32d056c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>多拼几个就成这样了<code>&#39;e&#39;+Array(50).join(&#39;\u0301&#39;)</code>  </p>
<p>é́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́́<br><img src="https://upload-images.jianshu.io/upload_images/17817191-656a4441bdc99862.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>继续拼接字符 <code>&#39;很好玩&#39;+Array(50).join(&#39;\u0310&#39;)+Array(50).join(&#39;\u0598&#39;)+Array(50).join(&#39;\u0e49&#39;);</code></p>
<p>很好玩้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้้̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐̐֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘֘</p>
<h3 id="零长度短网址"><a href="#零长度短网址" class="headerlink" title="零长度短网址"></a>零长度短网址</h3><p> <a href="https://zws.im/" target="_blank" rel="noopener">https://zws.im/</a>  这个网站用不可见字符欺骗你的视觉。<br>输入网易云音乐网址后的地址变成了<code>https://zws.im/​‌​​​‌​​‌‌​​‌​/</code>，看起来不是网易的地址却跳转到了网易。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-1b44e1e184bde63f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>当然这个生成服务在墙外，所以有人开发了国内版 <a href="https://ml.mk/" target="_blank" rel="noopener">https://ml.mk/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-4db642a7bd31f999.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>网易云音乐的短网址就是 <code>https://ml.mk/‌‌‌‌‌‌‌‌​‌​​​‌​‌/</code>，如果是某个不可描述网站生成这样的短网址，然后你在办公室打开就尴尬了，所以说不要随意打开这些不认识域名的网站。</p>
<p>另外有人还做了个零宽字符隐藏加密网站 <a href="http://morse.rovelast.com/，原理是利用零宽字符这种在文本中不显示的特殊字符，对加密文本进行转码，嵌入到普通文本当中，从而隐藏加密内容；表面看起来是一段普通文本，复制粘贴不会丢失。" target="_blank" rel="noopener">http://morse.rovelast.com/，原理是利用零宽字符这种在文本中不显示的特殊字符，对加密文本进行转码，嵌入到普通文本当中，从而隐藏加密内容；表面看起来是一段普通文本，复制粘贴不会丢失。</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-d348856dcba4ed70.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>参考： </p>
<p>  <a href="http://www.asciim.com/ascii/265.html" target="_blank" rel="noopener">http://www.asciim.com/ascii/265.html</a><br><a href="https://www.utf8-chartable.de/unicode-utf8-table.pl" target="_blank" rel="noopener">UTF-8 encoding table and Unicode characters</a><br><a href="https://unicode-table.com/cn/#control-character" target="_blank" rel="noopener">字符百科</a><br><a href="https://mengkang.net/740.html" target="_blank" rel="noopener">去掉不可见字符</a><br><a href="http://ctf.ssleye.com/jinzhi.html" target="_blank" rel="noopener">进制转换</a><br><a href="http://www.fileformat.info/info/unicode/category/Mn/list.htm" target="_blank" rel="noopener">Unicode Characters in the ‘Mark, Nonspacing’ Category</a><br><a href="https://www.playpi.org/2018090601.html" target="_blank" rel="noopener">踩坑特殊字符之硬空格</a><br><a href="http://www.asciim.com/ascii/265.html" target="_blank" rel="noopener">过滤ASCII码中的不可见字符</a><br><a href="https://linux.cn/article-2137-1.html" target="_blank" rel="noopener">Linux终端：用cat命令查看不可见字符</a><br><a href="https://www.cnblogs.com/52cik/p/unicode-mark-nonspacing.html#!comments" target="_blank" rel="noopener">奇葩字符 “a๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎๎” 的简单分析</a><br><a href="https://github.com/rover95/morse-encrypt" target="_blank" rel="noopener">使用零宽字符，隐藏存储加密信息</a><br><a href="https://github.com/asiacny/zero-width-qrcode-sqlite-shortener" target="_blank" rel="noopener">可生成零宽度地址与二维码的PHP短网址程序</a></p>
<p>推荐阅读：</p>
<p><a href="https://mp.weixin.qq.com/s/-cSjrvkibYGp5Fx8gCTFuw" target="_blank" rel="noopener">那些你可能不知道的浏览器奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/eGDO0Y8el_dsEyriCoAgog" target="_blank" rel="noopener">那些你可能不知道的微信奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/j7VhoZXmUTnOWC5C_B8jlQ" target="_blank" rel="noopener">那些你可能不知道的微博奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/LtI2piwAIDXA590NEsXvuw" target="_blank" rel="noopener">那些你可能不知道的网易云音乐奇技淫巧</a></p>
<p> <a href="https://mp.weixin.qq.com/s?__biz=MzIyMjg2ODExMA==&amp;mid=2247483979&amp;idx=1&amp;sn=0735daa1d805b66d346ed0e8e60a841f&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">那些你可能不知道的搜索奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzIyMjg2ODExMA==&amp;mid=2247483983&amp;idx=1&amp;sn=f0e1d9a8e22caf609d6c21431a530186&amp;chksm=e827a5aedf502cb8b72f2036054753fcfd9c20c28b9fbccdeae619a254a80e1024f18ba06523&amp;token=457023358&amp;lang=zh_CN#rd" target="_blank" rel="noopener">那些你可能不知道的视频下载奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/R3x-xZwqLIVwPjlgikDQ9A" target="_blank" rel="noopener">那些你可能不知道的免费观看 VIP 视频奇技淫巧</a></p>
<p><a href="https://mp.weixin.qq.com/s/sqRgMh4rxFBt5YxNtaa6dw" target="_blank" rel="noopener">那些你可能不知道的知乎奇技淫巧</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-393b26173c148690.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="免费星球"></p>
<h3 id="公众号：苏生不惑"><a href="#公众号：苏生不惑" class="headerlink" title="公众号：苏生不惑"></a>公众号：苏生不惑</h3><p> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/07/29/2018-那些事儿/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/07/29/2018-那些事儿/" itemprop="url">2018 那些事儿</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-07-29T20:55:03+08:00">
                2019-07-29
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.2k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  4 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>最近新浪食堂换新的供应商，饭好吃多了。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-5d18c916c0e108c4?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-dfc5164391f77bfd?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-8544abb8f7e4d0f3?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-7f36f76d1d4d0308?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-c3e07bf88f5127df?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>过去一年发生很多事，这里做个总结。</p>
<p>之前发布了网易，微博，知乎等总结  <a href="http://mp.weixin.qq.com/s?__biz=MjM5ODIzNDExMg==&amp;mid=2257484343&amp;idx=1&amp;sn=f825eb0eb3f30c2e2c2a8519ed352837&amp;chksm=a5b70b5892c0824ee2491de37e55d7b075effd0df9878952d311e9612d965d806cb0c69c1719&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">我的2018年</a></p>
<p>现在中国移动也来了。 <a href="https://mp.weixin.qq.com/s?__biz=MjM5Nzg1NTQyMQ==&amp;mid=2677710975&amp;idx=1&amp;sn=63277b749a5c7fc025eaeef96a715ed3&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">查看你的2018移动账单‼️最高1GB‼️</a>  平均一个月消费67，几乎都是流量。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-e8cd424cdb84dc61?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-33d3a7bd2321c816?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-7f2c6b10517c50d3?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-fcd5732e61dee9aa?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<pre><code>这个号码是我妈的
</code></pre><p>今天看到一条微博很有意思，原来微博办公已经实现了，微博的确改变了这个世界。<a href="https://weibo.com/3227812037/HazHWChaH" target="_blank" rel="noopener">https://weibo.com/3227812037/HazHWChaH</a> ： </p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-354c9a5c4dd5bf32?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-86503041e5cc85be?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-59f0423920b42548?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-f6f2df980742fc4d?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>另外 2018微信数据报告 的70后、80后、90后、00后的人群分析，有、意思  <a href="https://weibo.com/2357213493/Hb7J6gvRB" target="_blank" rel="noopener">https://weibo.com/2357213493/Hb7J6gvRB</a>  <a href="https://support.weixin.qq.com/cgi-bin/mmsupport-bin/getopendays?from=groupmessage&amp;isappinstalled=0" target="_blank" rel="noopener">https://support.weixin.qq.com/cgi-bin/mmsupport-bin/getopendays?from=groupmessage&amp;isappinstalled=0</a> </p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-c0517ad8bb298fc5?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-b38b6d3e46b643a1?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-e1896747e2143eda?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-711c8ae191684e22?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-ae68c0909a75f454?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-67eba7198bc1734f?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>微信8年啦！除了2019 微信公开课张小龙分享的干货外，以下这14条微信“潜规则”你也应该知道！欢迎对号入座 <a href="https://weibo.com/1742566624/HbkVbaj4c" target="_blank" rel="noopener">https://weibo.com/1742566624/HbkVbaj4c</a> </p>
<p><a href="https://wx2.sinaimg.cn/mw690/a1eface5ly1fz1qti4st3j20u085znpd.jpg" target="_blank" rel="noopener">https://wx2.sinaimg.cn/mw690/a1eface5ly1fz1qti4st3j20u085znpd.jpg</a> </p>
<p>你置顶了谁，谁又置顶了你？</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-2e9e65d988f435b9?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>再看新榜的微信公众号总结 <a href="https://mp.weixin.qq.com/s?__biz=MzAwMjE1NjcxMg==&amp;mid=2654672254&amp;idx=1&amp;sn=11a3b97d9d276c9d8fd36b8e5f595abe&amp;chksm=810104b9b6768daf229566e75325d31f1e2f89230b420dc2c7b60cad1409944dbd21be0dca38&amp;mpshare=1&amp;scene=21&amp;srcid=0104OdNC6QFJloP27yW1SXnx&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAFACOXHgBXmR4Am5keAJ2ZHgCjmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=5fcjzLZY8nAd7WJTBZ8fvz2Nw5/0yZKtrmwajrNgt%20owE6VuZKJ%201/5W8TjJpHnO&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">公众号的2018</a>  <a href="https://mp.weixin.qq.com/s?__biz=MzAwMjE1NjcxMg==&amp;mid=2654671988&amp;idx=2&amp;sn=aaac75c0bcf1a903062e872436c27e67&amp;chksm=810105b3b6768ca53ff4173eee13019452bee153de726b6f1c0366429a4d9d0f25d0c2929aeb&amp;mpshare=1&amp;scene=21&amp;srcid=1231ilhZNbokYtLAxVkYpXKS&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAFACOXHgBXmR4Am5keAJ2ZHgCjmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=vqvwN8A9lT1Cg6kP0OdUDxWILDxc1/pJQeev/k2a5Foxhk6iqLQhTjg95eE45a1U&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">2018，无法撤回</a>  <a href="https://mp.weixin.qq.com/s?__biz=MzAwMjE1NjcxMg==&amp;mid=2654672316&amp;idx=1&amp;sn=8b8350b793a3f8e288b7f55ddd614362&amp;chksm=8101047bb6768d6d229c3c604372cd0467d479f3bbbe33664442aa5483ba361b99a626b3c26b&amp;mpshare=1&amp;scene=21&amp;srcid=0106TFHVnho4LvSWYXJWp6EM&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=27000038&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAGACOXHgBXmR4Am5keAJ2ZHgCjmR4As5keAAAA&amp;lang=zh_CN&amp;pass_ticket=os0oh%20IZdLx%20aDsZPG7o00lQN1g5c4hQqPsbtpOn4Hie5oswKrr7aOHXbRHTMWMP&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">2018年中国微信500强年报</a><a href="https://cu2018.newrank.cn/h5.html?n=2b0039&amp;from=timeline" target="_blank" rel="noopener">https://cu2018.newrank.cn/h5.html?n=2b0039&amp;from=timeline</a> </p>
<p>今年正好是改革开放40年，人民日报发了40年变化，很形象 <a href="https://mp.weixin.qq.com/s?__biz=MjM5MjAxNDM4MA==&amp;mid=2666230142&amp;idx=1&amp;sn=edd1abf407e13ac36e22f525dc5a83e2&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">幸福长街40号</a>  ，地址  <a href="https://c.h5in.net/people/" target="_blank" rel="noopener">https://c.h5in.net/people/</a> 而且里面居然发现了周杰伦，可见杰伦对华语音乐的贡献。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-0c0f9be4f3428121?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>最后推荐一些朋友的2018总结和好文：</p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI2NDA0NDM1MA==&amp;mid=2650106348&amp;idx=1&amp;sn=928ad4610d64a52c49c33aaf96ca1dd0&amp;chksm=f2b363bdc5c4eaabecf7f79cf8abfd6aef7c58cf44bf570ae8a9813827d9db36da1e27563529&amp;mpshare=1&amp;scene=21&amp;srcid=0107JAMU0mMeDHYsB5au26nk&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=27000038&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAGACOXHgBXmR4Am5keAJ2ZHgCjmR4As5keAAAA&amp;lang=zh_CN&amp;pass_ticket=os0oh%20IZdLx%20aDsZPG7o00lQN1g5c4hQqPsbtpOn4Hie5oswKrr7aOHXbRHTMWMP&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">我的2018年个人总结</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MjM5MzgyODQxMQ==&amp;mid=2650369793&amp;idx=1&amp;sn=b5476eea7d98d5b6eecaff1afbc69aa2&amp;chksm=be9cd45589eb5d43c8ba6a7b56410088a9d00e0ef06a7545248b07467d444588145fd9d68fe6&amp;mpshare=1&amp;scene=21&amp;srcid=0110RSRpB0EAfcyD0naKcxah&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=27000038&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAGACOXHgBXmR4Am5keAJ2ZHgCjmR4As5keAAAA&amp;lang=zh_CN&amp;pass_ticket=os0oh%20IZdLx%20aDsZPG7o00lQN1g5c4hQqPsbtpOn4Hie5oswKrr7aOHXbRHTMWMP&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">python之禅公众号文章目录</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MjM5MTQ4NjA3Nw==&amp;mid=2459679291&amp;idx=1&amp;sn=c5062f89f10f12d9cb2bfb3132f3555f&amp;chksm=b1dbc32986ac4a3f67a09e1afd20337c439b84a81df54c34166d8387b7dce6899091f5a5fa52&amp;mpshare=1&amp;scene=21&amp;srcid=0108BeXqtj8pQ4Fjor6Q5x9i&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=27000038&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAGACOXHgBXmR4Am5keAJ2ZHgCjmR4As5keAAAA&amp;lang=zh_CN&amp;pass_ticket=os0oh%20IZdLx%20aDsZPG7o00lQN1g5c4hQqPsbtpOn4Hie5oswKrr7aOHXbRHTMWMP&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">学Python前请你先看看这个文章</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI5NDY1MjQzNA==&amp;mid=2247488585&amp;idx=1&amp;sn=f4bc0735dd8b63b5ebcf44073093bf0f&amp;chksm=ec5ecb34db2942223960b39420fea2e9c77d5b316ed38b7fc9e407a7bad6c90c1682e1fc82e0&amp;mpshare=1&amp;scene=21&amp;srcid=0119gyf3zbxXpcxh4qH55PbI&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=2700003a&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwATABQABQAjlx4AV5keAJuZHgCdmR4As5keAAAA&amp;lang=zh_CN&amp;pass_ticket=6VJzwCwFHVSLN73jjoZKoALLoknS2Jv2Hli6iqoDsj87mAMYCyoyNQyYARS8F6Z2&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">2018年Python爱好者社区历史文章合集</a></p>
<p><a href="https://2018.juejin.im" target="_blank" rel="noopener">https://2018.juejin.im</a> 2018 掘金年度总结</p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI4ODU2ODMxOA==&amp;mid=2247484668&amp;idx=1&amp;sn=b49f637657422b94da9a67d0edc49906&amp;chksm=ec3d226ddb4aab7b8c4658b42b8bbd2b4236da47348864651170bbc243b9d265a40276f1f930&amp;mpshare=1&amp;scene=21&amp;srcid=&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=27000038&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAGACOXHgBXmR4Am5keAJ2ZHgCjmR4As5keAAAA&amp;lang=zh_CN&amp;pass_ticket=os0oh%20IZdLx%20aDsZPG7o00lQN1g5c4hQqPsbtpOn4Hie5oswKrr7aOHXbRHTMWMP&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">老薛星球的 精华摘选</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI3MjE3NDI4MQ==&amp;mid=2247484213&amp;idx=1&amp;sn=cd90d280b1bcd7b9a669283963fdb030&amp;chksm=eb37de93dc4057859f80a6dea22341c7f7b2d8ed2cb9d41c6c22ac91113e529b472125a353aa&amp;mpshare=1&amp;scene=21&amp;srcid=0102eiyvKq0emhMkSNXPcjHP&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAFACOXHgBXmR4Am5keAJ2ZHgCjmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=5fcjzLZY8nAd7WJTBZ8fvz2Nw5/0yZKtrmwajrNgt%20owE6VuZKJ%201/5W8TjJpHnO&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">2018年：自由这一年</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI5MzE4MTIwMQ==&amp;mid=2247484133&amp;idx=1&amp;sn=9b4fd8319ef13836236bed4755fc59f3&amp;chksm=ec77409bdb00c98d7c5bc9b4907393d05fd33ed016a8aa740e6440d99233db1306f088bf1794&amp;mpshare=1&amp;scene=21&amp;srcid=&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAFACOXHgBXmR4Am5keAJ2ZHgCjmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=5fcjzLZY8nAd7WJTBZ8fvz2Nw5/0yZKtrmwajrNgt%20owE6VuZKJ%201/5W8TjJpHnO&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">我所知道的寒江雪</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzAwNjYxNzc0OA==&amp;mid=2649543350&amp;idx=1&amp;sn=e45732925f6ac3f64125a2e5ac2ef671&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">罗振宇2018“时间的朋友”跨年演讲精华版全文</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzIxODUxMDM5MQ==&amp;mid=2247484442&amp;idx=1&amp;sn=ee5f89e0bec09f052ee241308077b77a&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">分析了10个公众号5600篇文章2000w字</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MjM5NzY2OTE2MQ==&amp;mid=2652220698&amp;idx=1&amp;sn=9d155a261ec08fc7f339c4ee53162105&amp;scene=21&amp;token=1323997581&amp;lang=zh_CN#wechat_redirect" target="_blank" rel="noopener">一年过去，我读过的十佳好文</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzA3NTg0NDQyNQ==&amp;mid=2649631772&amp;idx=1&amp;sn=923fcf50c720506fcf02cdfbf5bb5490&amp;chksm=8770d23ab0075b2c0a6ee38f19a3590c06a1f95221c8846fec3603a767f0c9e67052ce187af2&amp;mpshare=1&amp;scene=21&amp;srcid=1030MVSkowC213yQTGJA5N8H&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=KKTtGpJq6m0Q36OrNuCseleemQf4yIexkofmQsdIU1Mw2mMfi6FpAz1iZxQ%20/L48&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">金庸│人生就是大闹一场，悄然离去</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzAwMjE1NjcxMg==&amp;mid=2654670026&amp;idx=1&amp;sn=c226f8767d77ad4d4c18ce0eabbfe2bd&amp;chksm=81011d0db676941beb06cd80df2907c6d341bd2afd95c77b5e3fe116f4b09484894e03f30b00&amp;mpshare=1&amp;scene=21&amp;srcid=1031aAY9dIVBEKuqG9GeTtp5&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=KKTtGpJq6m0Q36OrNuCseleemQf4yIexkofmQsdIU1Mw2mMfi6FpAz1iZxQ%20/L48&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">金庸去世，失去了后台的新媒体人不只六神</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzIxNjA2ODUzNg==&amp;mid=2651436591&amp;idx=1&amp;sn=df61e9adea4e518bc0d98437ed0f65d4&amp;chksm=8c73aef8bb0427ee6934b90a5fb27a2b12834e266fb266e3e0f70402e4de4f7ffeb34f6391d4&amp;mpshare=1&amp;scene=21&amp;srcid=1108kmXsYRUy3bQWDOXDunmX&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=ChuNMBWo77p5LUxarC1NnMAqWqj5NmSGuAGQgqbhW1nbmAzLj3wPBKoYacd5ecl%20&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">【整理】从零开始学Python系列</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI3OTU0MzI4MQ==&amp;mid=2247486619&amp;idx=1&amp;sn=2a41b045fec5d9e5b7d8c6ef0cf2e459&amp;chksm=eb476005dc30e91391130292d3d56610bea871ddff9aacdfa0641c3d78d9294524c1bf8ddf70&amp;mpshare=1&amp;scene=21&amp;srcid=1105NZWaUxcXjWMAXcloif4q&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=Ju5iyqMLDXiUpdVsRKPR2%20TnV4v7uuDKAYEm3YUFQ/uMea9eJh4lfpJxFkhylJVI&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">离职后，我是这样准备面试的</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzAxNzI4MTMwMw==&amp;mid=2651632397&amp;idx=1&amp;sn=9255ca9999227feeb8fe62f8acb5fb1a&amp;chksm=801feb75b7686263807f9685723bcfdbd613f21f006e455fcebebd20dadeb961079d7540812e&amp;mpshare=1&amp;scene=21&amp;srcid=1110bCY8elexKjEkGxNZnK8R&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=Ju5iyqMLDXiUpdVsRKPR2%20TnV4v7uuDKAYEm3YUFQ/uMea9eJh4lfpJxFkhylJVI&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">这些年我看到的所谓区块链</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI3OTU0MzI4MQ==&amp;mid=2247486688&amp;idx=1&amp;sn=e8683f8001ca746783f38bbed581e89a&amp;chksm=eb47607edc30e96800d79d23fcdb5a82e4fe664f035d7dd7260ad7dab5c0ff15c22559a0e35b&amp;mpshare=1&amp;scene=21&amp;srcid=1114XgMO7YzWeEGzmKvGTzB5&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=QMX65s4ncz0SEE/lSwY8wD9FidmTX6yVAr0DgTxvyFSQx9KSjtiqLZEjgvn8e2Qk&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">开发了5年android，我开始了go学习之旅</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzIwNTc4NTEwOQ==&amp;mid=2247486116&amp;idx=1&amp;sn=e47bbf49bd1a007f2f00631e2e937c38&amp;chksm=972adbdea05d52c8630a53968a71c7b23fc90a5530b0300229bc50c2e1f81ef0dd4d88b3ead5&amp;mpshare=1&amp;scene=21&amp;srcid=1116Z4YDWs2Zt7jAqW49ZsnN&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=QMX65s4ncz0SEE/lSwY8wD9FidmTX6yVAr0DgTxvyFSQx9KSjtiqLZEjgvn8e2Qk&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">【漫话】如何给女朋友解释什么是分布式和集群？</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzA5OTAyNzQ2OA==&amp;mid=2649699442&amp;idx=1&amp;sn=dd082101307152e79105d1ae4195cfc1&amp;chksm=88930b11bfe482073f0e8c80146180486aa9189c651e8daa4be6239da3a21449e8b0e83488dc&amp;mpshare=1&amp;scene=21&amp;srcid=1114QSIIYBxQwePbGlne9FrD&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=QMX65s4ncz0SEE/lSwY8wD9FidmTX6yVAr0DgTxvyFSQx9KSjtiqLZEjgvn8e2Qk&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">这可能是最为详细的Docker入门总结</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzIwNTc4NTEwOQ==&amp;mid=2247486191&amp;idx=1&amp;sn=5ea5fd098a3e0da834d882cf53529977&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">365篇高质技术文章目录整理，每天一点收获</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI0OTQyNzEzMQ==&amp;mid=2247487964&amp;idx=1&amp;sn=720e3d635a0ea81657e1d0e63496ecf2&amp;chksm=e990f408dee77d1ea58b6aa8905f8ae7cc6d6b6d14217c953d1395e4ddcec8540b8e1bab64d8&amp;mpshare=1&amp;scene=21&amp;srcid=11302t7ZsNkk7OabUzSpKScA&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwASABQABAAjlx4AV5keAJmZHgCgmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=lcnwKa5o8P7LF2gyCnMIG%20P5Jh8lyZQ0nGAwDqyybP/i8fGg7bpvMC0a%203SNc/eH&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">深度好文|面壁人张小龙，我是你的破壁人</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzUyNzE4MDM2MA==&amp;mid=2247491134&amp;idx=2&amp;sn=356a0d9a49f17d3834b485114b5f4638&amp;chksm=fa022919cd75a00f631649ce2711c83d8f65c4ece48974b5fe01e5fc215ad915c0a32dc56890&amp;mpshare=1&amp;scene=21&amp;srcid=1120wWS3zng7tJ0tp5clvf3L&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwANABQABAAjlx4AWZkeAImZHgCLmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=E7nhSzgyUUNUrBpvoGJ41P0KGxAiolcEej7x7/BYUhWIOxh7OstH6ioEJ0NbPjwJ&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">五分钟让你快速看懂区块链</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI1MzY0MzE4Mg==&amp;mid=2247484121&amp;idx=1&amp;sn=a0106977e6acdbb014d4c58d9c02d24d&amp;chksm=e9d01218dea79b0e11e97675e56e2b76e46e4c74091c1cc97de0b2cad9d86f25733942613759&amp;mpshare=1&amp;scene=21&amp;srcid=11304ZvDsXx5XBAH0iXh6kby&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwASABQABAAjlx4AV5keAJmZHgCgmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=lcnwKa5o8P7LF2gyCnMIG%20P5Jh8lyZQ0nGAwDqyybP/i8fGg7bpvMC0a%203SNc/eH&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">公众号历史文章及代码汇总</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzA3OTI0NzY5Mg==&amp;mid=2650366273&amp;idx=1&amp;sn=20d896fbf6fdf9a1c21921b708078d53&amp;chksm=87bba162b0cc2874a3f79acb8e5272d3d7900677cda2ad653bf93666fcb4783a884cc9753471&amp;mpshare=1&amp;scene=21&amp;srcid=1201IOurFJwySAtnATVktsjY&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BAABAAoACwASABQABAAjlx4AV5keAJmZHgCgmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=lcnwKa5o8P7LF2gyCnMIG%20P5Jh8lyZQ0nGAwDqyybP/i8fGg7bpvMC0a%203SNc/eH&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">如何快速入门新媒体运营</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzAxNjM2MTk0Ng==&amp;mid=2247485784&amp;idx=1&amp;sn=fcfb686701b156a70a80922c3e5959b8&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">MySQL索引优化看这篇文章就够了</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzA5Njg1OTI5Mg==&amp;mid=2651026400&amp;idx=1&amp;sn=3870a685a1dcd8efacd5eeea741d8db1&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">一边制造，一边讲解http状态码502|504|499|500</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI0NjAzNzcyMw==&amp;mid=2650296536&amp;idx=1&amp;sn=96a9d706ebe27db91fba2f35ef282429&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">2018国民年度流行语TOP100出炉了</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzI3OTU0MzI4MQ==&amp;mid=2247486799&amp;idx=1&amp;sn=dd61287c1c76d4c43c6fbad6664efe27&amp;chksm=eb4761d1dc30e8c76810a88e78307307ddec6a21b048473f5585c53c88bb4fc64a206491506b&amp;mpshare=1&amp;scene=21&amp;srcid=1211LlQccfMFYrqHJzv3xZUi&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAFACOXHgBXmR4AmZkeAJ2ZHgCjmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=pwDj/alFN1GOEUOREOAnniJG4o%201/Yzb/GrZCcrY1yS1udet1%20qstaj4iI9pbmvh&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">这样写简历，offer不给你给谁？</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzA3MDM3NjE5NQ==&amp;mid=2650837153&amp;idx=1&amp;sn=474d2e34bc97495c082546bd2e70ba37&amp;chksm=84c9fecdb3be77dbd1d1685d44c9e7ae6e386fda1234a3733127b2beb7ec5cca282affdcb81c&amp;mpshare=1&amp;scene=21&amp;srcid=1216hdJRC90jY4w3mgDMyPat&amp;from=timeline&amp;ascene=2&amp;devicetype=android-19&amp;version=26060772&amp;nettype=WIFI&amp;abtest_cookie=BQABAAoACwASABMAFAAFACOXHgBXmR4AmZkeAJ2ZHgCjmR4AAAA=&amp;lang=zh_CN&amp;pass_ticket=pwDj/alFN1GOEUOREOAnniJG4o%201/Yzb/GrZCcrY1yS1udet1%20qstaj4iI9pbmvh&amp;wx_header=1#wechat_redirect" target="_blank" rel="noopener">1988-2018，慢慢听，别哭啊</a></p>
<p>2018年最热流行语TOP20”榜单 <a href="https://weibo.com/3960037780/H9bJ9074D" target="_blank" rel="noopener">https://weibo.com/3960037780/H9bJ9074D</a></p>
<p>关于直销和传销的科普 <a href="https://weibo.com/5780974966/H8T0AiPAM" target="_blank" rel="noopener">https://weibo.com/5780974966/H8T0AiPAM</a></p>
<p>QQ发文回顾2008~2018年，十年间的标志性流行语  <a href="https://weibo.com/2357213493/H8UFAvrqt" target="_blank" rel="noopener">https://weibo.com/2357213493/H8UFAvrqt</a></p>
<p>网友给出的总结2018年中国的10个汉字，你最认可哪个 <a href="https://weibo.com/2836149552/H898Dspjg" target="_blank" rel="noopener">https://weibo.com/2836149552/H898Dspjg</a> </p>
<p>微博2018年数据回顾 <a href="https://weibo.com/1560906700/H8fVntJvA" target="_blank" rel="noopener">https://weibo.com/1560906700/H8fVntJvA</a> </p>
<p>我的时代和我 (2018) <a href="https://weibo.com/1856050627/H7DTKnhF6" target="_blank" rel="noopener">https://weibo.com/1856050627/H7DTKnhF6</a></p>
<p>一整年的乐儿都在这儿了！郭德纲、于谦、岳云鹏、孙越、张云雷的相声合集<a href="https://weibo.com/1662214194/H9JWf9b1K" target="_blank" rel="noopener">https://weibo.com/1662214194/H9JWf9b1K</a></p>
<p>网易“娱乐圈画传 <a href="https://ent.163.com/special/entphotos2018/" target="_blank" rel="noopener">https://ent.163.com/special/entphotos2018/</a></p>
<p>《2018年度热点图鉴》  <a href="https://weibo.com/5901272946/H9vGAhbtK" target="_blank" rel="noopener">https://weibo.com/5901272946/H9vGAhbtK</a></p>
<p>对于2018年，该说不该说的，鲁迅先生都帮我们说完了…… <a href="https://weibo.com/6421571119/H9vEOBxgb" target="_blank" rel="noopener">https://weibo.com/6421571119/H9vEOBxgb</a></p>
<p>「2018，我们用什么书写历史？」 <a href="https://weibo.com/2028810631/H9ARHhL3s" target="_blank" rel="noopener">https://weibo.com/2028810631/H9ARHhL3s</a></p>
<p>《成人世界黑话鉴定指南》  <a href="https://weibo.com/1618993981/H99M39vu0" target="_blank" rel="noopener">https://weibo.com/1618993981/H99M39vu0</a></p>
<p>豆瓣2018年度音乐榜单，回顾全年好音乐！ <a href="https://weibo.com/1742566624/H9hCs9aRh" target="_blank" rel="noopener">https://weibo.com/1742566624/H9hCs9aRh</a> </p>
<p>网上有个段子，中国近现代人生22个失误：</p>
<p>1911年当太监；<br>1916年投奔袁世凯；<br>1924年没去上黄埔军校；<br>1927年与吴佩孚孙传芳搞到一块；<br>1934年不敢冒死参加长征；<br>1937年为抗日参加了国军；<br>1945年入伪军；<br>1949年离开党组织又不敢接受老蒋的免费机票；<br>1948年农村买地；<br>1955年从城市跑去农村；<br>1957年参加会议一激动提了意见；<br>1966年下乡扎根和贫下中农结婚；<br>1976年投靠四人帮；<br>1980年看不起个体户；<br>1991年不敢开办公司；<br>1997年找门路到国企当了工人；<br>2003起年不敢买房子；<br>2012年才用心思把自己弄成贪官；<br>2015年10月结扎；<br>2017年3月从雄县迁出户口，<br>2018年满仓A股，<br>2019年辞职再就业。</p>
<p>2019年，稳定为主，好好赚钱，好好生活吧。</p>
<p> 人生就是一场轮回，看完感觉豁达了许多。  <a href="https://weibo.com/1742566624/HaHBKEPV8" target="_blank" rel="noopener">https://weibo.com/1742566624/HaHBKEPV8</a> </p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-4fe5841823bc0d43?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/07/29/2018-新浪年会/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/07/29/2018-新浪年会/" itemprop="url">2018 新浪年会</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-07-29T20:51:42+08:00">
                2019-07-29
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  769 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  2 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>这篇文章写于2019.1.19</p>
<p>这周通过了转正，真的很高兴，来新浪已经半年了，话说转正也是简单，直接发个邮件通知就行，不像之前的公司需要开个转正会议让大家来评判，感谢公司的认可。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-80cff357da61f001?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>一晃就到1月末了，这周三公司举行了年会，坐公司同事的车过去了，才发现公司好多人都有车，地下车库好多各种车，果然有钱人多。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-fb28d2de68e73a00?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-099e481d4e69578a?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-e4d8fbc9fc3d18d1?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-260a6747bb427ceb?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>年会地点在奥体中心，公司大，人也多，2点到了转了一圈才找到位置，然后3点开始。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-e464bec272beffc3?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-3ad7992e779a37e5?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-5371c52545db7787?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-08a31ad50f1d6d31?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-79b79cb7041d7f7d?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-b65f928b38c4b9e8?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-66db0a8a20202bfb?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-ab70be98e3fee2f3?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-7ff90163d98d5304?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>想起之前公司的年会，2016的5周年年会，翻了下当时的年会图片，当时还中奖了。<a href="https://weibo.com/2717930601/DeuVSBk17" target="_blank" rel="noopener">https://weibo.com/2717930601/DeuVSBk17</a>  </p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-bb689a3ebf26bdea?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-2aa8598ae4460e94?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-e8ce2c4bffb73e56?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-9a111d5eef678a9f?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-dcc0509f601cd469?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-0cc7160df8d84e84?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-2f7c24a00e0ab7e6?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-61bd82c47ba99ee5?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-56dfed62af4fc9d7?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>第一次参加大公司的年会，人山人海，不过今年没请什么明星，可能前几年比较流行，比如360请了泷泽萝拉，还流传了一段时间。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-9fa10b944f2c4f16?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-639868c441cef906?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>网上还看到一段周星驰 吴孟达在公司年会上的经典之作，推荐看看。<a href="https://weibo.com/2964493453/D492cpqwq" target="_blank" rel="noopener">https://weibo.com/2964493453/D492cpqwq</a> </p>
<p>下面是我拍的几个视频：</p>
<p>新浪年会之编辑部的故事 <a href="https://weibo.com/2717930601/HcxVkrM0G?from=page_1005052717930601_profile&amp;wvr=6&amp;mod=weibotime" target="_blank" rel="noopener">https://weibo.com/2717930601/HcxVkrM0G?from=page_1005052717930601_profile&amp;wvr=6&amp;mod=weibotime</a></p>
<p>新浪年会之夜空中最亮的星  <a href="https://weibo.com/2717930601/HcxLXcnky?from=page_1005052717930601_profile&amp;wvr=6&amp;mod=weibotime" target="_blank" rel="noopener">https://weibo.com/2717930601/HcxLXcnky?from=page_1005052717930601_profile&amp;wvr=6&amp;mod=weibotime</a></p>
<p>新浪年会之雪落下的声音 <a href="https://weibo.com/2717930601/HcxLy3fQy?from=page_1005052717930601_profile&amp;wvr=6&amp;mod=weibotime" target="_blank" rel="noopener">https://weibo.com/2717930601/HcxLy3fQy?from=page_1005052717930601_profile&amp;wvr=6&amp;mod=weibotime</a></p>
<p>新浪年会之年少有为 <a href="https://weibo.com/2717930601/HcxI4C0Iz?from=page_1005052717930601_profile&amp;wvr=6&amp;mod=weibotime" target="_blank" rel="noopener">https://weibo.com/2717930601/HcxI4C0Iz?from=page_1005052717930601_profile&amp;wvr=6&amp;mod=weibotime</a> </p>
<p>今年年会主题是大浪逐新，也是新浪20周年，所以大奖也多，看看这些：</p>
<p>特等奖</p>
<p>价值8万元的1克拉定制钻戒及香港往返机票</p>
<p>一等奖</p>
<p>iPhone XS 256G+iPad mini 4 128G+AirPods的Apple 大礼包</p>
<p>土耳其伊斯坦布尔+卡帕多其亚8日5晚旅游大奖，全程机票+酒店</p>
<p>二等奖</p>
<p>Apple iPhone XS</p>
<p>Apple Macbook Air</p>
<p>三等奖</p>
<p>戴森(Dyson) 吸尘器  V10</p>
<p>小米电视4S</p>
<p>四等奖</p>
<p>戴森(Dyson) 吹风机，括号新年限量版</p>
<p>Kindle oasis墨水屏电纸书</p>
<p>五等奖</p>
<p>友人水果蔬菜解毒机或Beats Power3运动耳机</p>
<p>六等奖</p>
<p>飞利浦空气净化加湿器或300元好利来购物卡</p>
<p> 竟然还有</p>
<p>20万元现金大奖</p>
<p>四位幸运儿分别获得5万元 </p>
<p>这还不够刺激！</p>
<p>新浪20周年“无与伦比暴风尖叫”奖</p>
<p>新浪股票2000股 </p>
<p>2000股什么概念？</p>
<p>大概人民币近80万！！！</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-0f49dd25d4838f39?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-e2967cfc2f07c210?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-e8e91fced19b8990?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>当时抽中2000股票的时候，那个中奖人没在现场，当时就心跳加速了，希望再抽一次抽中我，然而连续抽5次，都木有我。。。当然最惨的还是抽中没在现场的！死的心都有<a href="https://weibo.com/2357213493/Hcfz4j3yM?refer_flag=1001030103" target="_blank" rel="noopener">https://weibo.com/2357213493/Hcfz4j3yM?refer_flag=1001030103</a>_ </p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-ad571b16fb5fcab1?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-a475e5f25bb00a6c?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>
<p>更多高清无码图片查看这篇文章<a href="https://mp.weixin.qq.com/s?__biz=MzIzODExODk3Nw==&amp;mid=2650755527&amp;idx=1&amp;sn=f9db1cf3addd860584da3bda79b08215&amp;chksm=f135c0e9c64249ff9e7073aa37f49315b9d6d77cd506abdd983a4e8109cd65fd224c54949f0b&amp;mpshare=1&amp;scene=21&amp;srcid=0116Pmp18rA7GGmCfrvgBNFF&amp;from=timeline&amp;#wechat_redirect" target="_blank" rel="noopener">重头大戏，新浪年会现场竟然</a> 或者点击原文 。<a href="https://live.photoplus.cn/activity/live/pc/4321855/#/" target="_blank" rel="noopener">https://live.photoplus.cn/activity/live/pc/4321855/#/</a>  </p>
<p>另外下周六部门年会，祝自己好运吧，也祝大家升职加薪暴富。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-bfed32da328bc45c?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"> </p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-440ecebfb280f3fd?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/30/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/30/">30</a><span class="page-number current">31</span><a class="page-number" href="/page/32/">32</a><span class="space">&hellip;</span><a class="page-number" href="/page/39/">39</a><a class="extend next" rel="next" href="/page/32/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">苏生不惑</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">382</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">37</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/sushengbuhuo" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mysusheng@gmail.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://plus.google.com/mysusheng" target="_blank" title="Google">
                      
                        <i class="fa fa-fw fa-google"></i>Google</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://v2ex.com/" title="v2ex" target="_blank">v2ex</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.fanhaobai.com/" title="fanhaobai" target="_blank">fanhaobai</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://yuanxuxu.com/archives/" title="yuanxuxu" target="_blank">yuanxuxu</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.snail-c.cn/article" title="snail-c" target="_blank">snail-c</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://showcj.com/archives" title="showcj" target="_blank">showcj</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://vultr.aicnm.com/%E6%9C%80%E6%96%B0Vultr%E6%B3%A8%E5%86%8C%E5%8F%8AVPS%E8%B4%AD%E4%B9%B0%E5%9B%BE%E6%96%87%E6%95%99%E7%A8%8B/" title="vultr" target="_blank">vultr</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.lucissfer.com/" title="lucissfer" target="_blank">lucissfer</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.csdn.net/fdipzone/article/details/79352685" title="傲雪星枫" target="_blank">傲雪星枫</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.yoby123.cn/index.php/category/default/" title="小白的分享" target="_blank">小白的分享</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.cnblogs.com/52fhy/p/5819995.html" title="PHP攻城狮" target="_blank">PHP攻城狮</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.jiaojie.site/" title="php" target="_blank">php</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://sphard.com/archives/" title="sphard" target="_blank">sphard</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://yuanxuxu.com/archives/" title="LNMP技术栈笔记" target="_blank">LNMP技术栈笔记</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.coding10.com/" title="学习 Laravel" target="_blank">学习 Laravel</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://shuwoom.com/?page_id=929" title="区块链学习指南" target="_blank">区块链学习指南</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://greenlightt.github.io/archives/" title="greenlightt" target="_blank">greenlightt</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.0php.net/archives/" title="0php" target="_blank">0php</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.fordba.com/category/mysql" title="mysql" target="_blank">mysql</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.itcodemonkey.com/" title="程序员" target="_blank">程序员</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.yanshuo.me/r/v2ex" title="言说" target="_blank">言说</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.timiguo.com/archive.html" title="提米果的博客" target="_blank">提米果的博客</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://phpartisan.cn/news/112.html" title="phpartisan" target="_blank">phpartisan</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.cnblogs.com/52fhy/" title="飞鸿影" target="_blank">飞鸿影</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.54php.cn/" title="54php" target="_blank">54php</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.lazyman.vip/" title="营销" target="_blank">营销</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.njphper.com/archives/" title="做人呢最重要的就是开心" target="_blank">做人呢最重要的就是开心</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.h57.pw/" title="php 初心者" target="_blank">php 初心者</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">苏生不惑</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>



<div>
<span id="showDays"></span>

</div>

<span id="busuanzi_container_site_pv">
   总访问量:<span id="busuanzi_value_site_pv"></span>次
</span>



  <span class="post-meta-divider">|</span>



<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共773.8k字</span>
</div>
<script>
var birthDay = new Date("11/20/2018");
var now = new Date();
var duration = now.getTime() - birthDay.getTime();
var total= Math.floor(duration / (1000 * 60 * 60 * 24));
document.getElementById("showDays").innerHTML = "本站已运行 "+total+" 天";
</script>

        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  











<script type="text/javascript">
    (function() {
        // 匿名函数，防止污染全局变量
        var utterances = document.createElement('script');
        utterances.type = 'text/javascript';
        utterances.async = true;
        utterances.setAttribute('issue-term','0')
        utterances.setAttribute('theme','')
        utterances.setAttribute('repo','sushengbuhuo/laravel_ioc_demo')
        utterances.crossorigin = 'anonymous';
        utterances.src = 'https://utteranc.es/client.js';
        // content 是要插入评论的地方
        document.getElementById('gitment-container').appendChild(utterances);
    })();
</script>


  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  

  
<script>
  ((window.gitter = {}).chat = {}).options = {
    //room替换成自己的聊天室名称即可，room的名称规则是：username/roomname
    room: 'sushengbuhuo-chat/mychat'
  };
</script>
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>

</body>
</html>
